Home > Net >  pandas python cant read data with doublequote
pandas python cant read data with doublequote

Time:02-01

Sorry if there is a duplicate post, because I've tried some method which was found in google but I did not get solution for my problem.

I've sample data like this:

kol1,kol2,kol3

abc,"def",ghi

I've try to open the file with this syntax:

pd.read_csv(file_name, sep=',')

or

pd.read_csv(file_name, sep=',' quotechar='"')

or

pd.read_csv(file_name, sep=',', engine='python')

but I get a dataframe like this:

kol1,kol2,kol3

abc,"def",ghi NaN NaN

the value which was in kol2 and kol3 is merged in kol1.

Can anybody help me how to read pandas dataframe with separated file comma and have row with double quotes?

CodePudding user response:

Try something like this:

Data

kol1,kol2,kol3
abc,"def",ghi

Load data with pd.read_csv and the delimiter="!#":

import pandas as pd
df = pd.read_csv("/content/data.csv", delimiter="!#")
  kol1,kol2,kol3
0  abc,"def",ghi

CodePudding user response:

If it doesn't work in double-quotes so use single quotes. If you want to use something like he's so use backslash '' in the sentence. BTW it may be a bug try to reinstall. I hope you understand.

  •  Tags:  
  • Related