Reputation: 1297
This is a fragment of csv file:
"tac,""vendor"",""platform"",""type"""
"00100429,""PROTO"",""Proprietary"",""Phone"""
"00100430,""PROTO"",""Proprietary"",""Phone"""
"00100431,""PROTO"",""Proprietary"",""Phone"""
I read it with:
pd.read_csv("path/name.csv", sep=",")
But it returns a dataframe with one merged column:
tac,"vendor","platform","type"
0 00100429,"PROTO","Proprietary","Phone"
1 00100430,"PROTO","Proprietary","Phone"
2 00100431,"PROTO","Proprietary","Phone"
3 00100432,"PROTO","Proprietary","Phone"
4 00100433,"PROTO","Proprietary","Phone"
5 00100434,"PROTO","Proprietary","Phone"
6 00100435,"PROTO","Proprietary","Phone
Obviously, i need all filed to be separated by ","
Upvotes: 1
Views: 61
Reputation: 294228
Use a different quotechar
pd.read_csv("path/name.csv", quotechar="'") \
.replace('"', '', regex=True).rename(columns=lambda x: x.strip('"'))
tac vendor platform type
0 00100429 PROTO Proprietary Phone
1 00100430 PROTO Proprietary Phone
2 00100431 PROTO Proprietary Phone
Upvotes: 3