0

I have CSV that i want to convert to JSON, i use pandas and it works fine except for lists. Is there any parameter or way to get the result i'm expecting ?

I used pandas to read my csv and the method .to_json(), in order to convert to JSON and it works fine. But the result i get for my lists is not what i was expecting.

read = pd.read_csv('path.csv', delimiter = "\t")
read.to_json('path.json' , orient = 'records')

my csv line for "college" is

28     ["Associations", "collectivités territoriales"...
29     ["Associations", "collectivités territoriales"...

111                                          ["PME-PMI"]
112                                          ["PME-PMI"]

And when i convert it i get :

  {
    "site": "NA",
    "college": "[\"Associations\", \"collectivités territoriales\", \"pôles de compétitivité\", \"groupements divers\"]",
  },

when i was expecting :

  {
    "site": "NA",
    "college": [
      "Associations",
      "collectivités territoriales",
      "pôles de compétitivité",
      "groupements divers"
    ],
  },

I don't want the quote around college list ”[]" And want it like that []

0 Answers0