1

I am trying to read a csv file with rows in the format :

A,B,"C,D",E

I want to have as an output :

   A   B  C,D   E

I used

df = pd.read_csv('/path/to/file_name',sep=",")

But it doesn't give the desired output. Any idea how to solve this ?

1 Answer 1

1
df = pd.read_csv('/path/to/file_name',sep=",",quotechar='"')

Specify the quotechar argument to ", then it will interprete everything between double quotes as part of a string (including the , character in the string).

Sign up to request clarification or add additional context in comments.

2 Comments

I tried that but it still gives me all the row content in first column then the rest of columns are filled with NaN
Then you have to look at the file you want to read-in carefully. Is there a first row which is commented out?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.