Pandas Csv Parser Not Working Properly When It Encounters `"`
Problem statement: Initially what I had I have a CSV file with the below records:- data.csv:- id,age,name 3500300026,23,'rahul' 3500300163,45,'sunita' 3500320786,12,'patrick
Solution 1:
You can tell pandas that you don't want double quotes to be treated specially by adding an argument to read_csv:
test_data2=pd.read_csv('data.csv', quoting=csv.QUOTE_NONE)
to read_csv()
. The output will be:
In [11]: df
Out[11]:
id age name
0 "3500300026 23 "rahul"
1 "3500300163 45 "sunita"
2 "3500320786 12 "patrick"
3 "3500321074 41 "Viper"
4 "3500321107 54 "Dawn Breaker"
parsing only on the comma.
Post a Comment for "Pandas Csv Parser Not Working Properly When It Encounters `"`"