Issue with format when parsing activity.txt
ghostSystem opened this issue · comments
Hi,
If I try to parse activity.txt file using Pandas, I get the output in a weird format.
Even though the columns are separate in activity.txt file, after parsing it through pandas all the columns are merged as one.
Is there a workaround to separate out the columns/clean the data so that it can be processed further ?
I came up with my solution to parse the data so that we can perform some data analysis on it.
I converted the activity.log file into a pandas DataFrame. (refer the image in the first post for the initial output).
Please do have a look. Will hardly take 5 mins. Do share your comments.
This is no more than 2 lines of code to convert the file to a DataFrame
.
def psrecord2df(path):
data = open(path).read().splitlines()[1:]
data = [[float(c) for c in l.split()] for l in data]
return pd.DataFrame(
data=data,
columns=['Elapsed time', 'CPU (%)', 'Real (MB)', 'Virtual (MB)'])
I think the ticket can be closed.