Skip to content
Advertisement

How to parse the log data which is in form of nested [key=value] format using python pandas

I have huge Sensor log data which is in form of [key=value] pair I need to parse the data column wise i found this code for my problem

JavaScript

the above code is suitable when the data is in form of “Priority=0, X=776517049” but my data is something like this [Priority=0][X=776517049] and there is no separator in between two columns how can i do it in python and i am sharing the link of sample data here raw data and bilow that expected parsed data which i done manually https://docs.google.com/spreadsheets/d/1EVTVL8RAkrSHhZO48xV1uEGqOzChQVf4xt7mHkTcqzs/edit?usp=sharing kindly check this link

Advertisement

Answer

I’ve downloaded as csv.

Since your file has multiple tables on one sheet, I’ve limited to 100 rows, you can remove that parameter.

JavaScript

Then you can use a regex to extract the values:

JavaScript

and set column names:

JavaScript

result:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement