I have a CSV file with the following format/content and would like to see an easier way to further parse the col3 content (delimited) to include them to CSV file by using python.
I'm new to this and the simple looping approach should be working but I would like to know any easier and faster way to implement this.
From:
col1,col2,col3,col4
1,"David","Job=Sales Manager;Hobby=reading;Sex=Male","31"
2,"Mary","Job=Nurse;Hobby=hiking;Sex=Female","23"
to:
col1,col2,Job,Hobby,Sex,col4
1,"David","Sales Manager","reading","Male","31"
2,"Mary","Nurse","hiking","Female","23"
You can use
pandas
library which helps deal with tabular data in a pretty easy way:To write out as
.csv
, simply callto_csv()
:new_df.to_csv("newXXX.csv")