0

I need to delete the quotes from the csv. I have a list of dictionaries of the following structure.

dicc= {"name":name, "number":number}
for i in api:
  list.append(dicc)

df=pd.DataFrame(list,columns= ['name', 'number'])
export_csv = df.to_csv (r'/name.csv', index = None, header=True,quoting= False)

The result is

name, number
A, 2
B, "1,2,3,4"
C, 3

The result I want:

name, number
A, 2
B, 1,2,3,4
C, 3

The format of the result is a comand "cat" of the csv. I need delete de quotes in the list. I tried a replace and it didn't work.

Solution

export_csv = df.to_csv (r'/name.csv', index = None, header=True,sep="|")

Or separate the list of numbers by another character that is not ","

SecretAgentMan
  • 2,856
  • 7
  • 21
  • 41
  • Possible duplicate of [Python Pandas: How to replace a characters in a column of a dataframe?](https://stackoverflow.com/questions/28986489/python-pandas-how-to-replace-a-characters-in-a-column-of-a-dataframe) – Erfan Aug 12 '19 at 12:32
  • `df['number'] = df['number'].str.replace('"', '')` – Erfan Aug 12 '19 at 12:33
  • I tried and not found... Is not duplicated, the solution not found. Thanks – Dani Martinez Aug 13 '19 at 12:48

1 Answers1

0

export_csv = df.to_csv (r'/name.csv', index = None, header=True,sep="|")

Or separate the list of numbers by another character that is not ","