Good afternoon, everybody.
I know that it is quite an easy question, although, I simply do not understand why it does not work the way I expected.
The task is as following:
I have a file data.csv presented in this format:
id,"feature_1","feature_2","feature_3"
00100429,"PROTO","Proprietary","Phone"
00100429,"PROTO","Proprietary","Phone"
The thing is to import this data using pandas. I know that by default pandas read_csv uses comma separator, so I just imported it as following:
data = pd.read_csv('data.csv')
And the result I got is the one I presented at the beginning with no change at all. I mean one column which contains everything.
I tried many other separators using regex, and the only one that made some sort of improvement was:
data = pd.read_csv('data.csv',sep="\,",engine='python')
On the one hand it finally separated all columns, on the other hand the way data is presented is not that convenient to use. In particular:
"id ""feature_1"" ""feature_2"" ""feature_3"""
"00100429 ""PROTO"" ""Proprietary"" ""Phone"""
Therefore, I think that somewhere must be a mistake, because the data seems to be fine.
So the question is - how to import csv file with separated columns and no triple quote symbols?
Thank you.
have a file data.csv presented in this format:
, because yur sample data working withsep=','
very nice. Can you create better data sample which return your bad output? – jezrael Nov 24 '18 at 7:16sep="\,"
, simply usesep=","
dont put `` – Karn Kumar Nov 24 '18 at 8:04data = pd.read_csv("sample.csv", sep="\,",engine='python')
gives me same output as your because or of that ``. – Karn Kumar Nov 24 '18 at 8:07