-2

I am trying to transfer a JSON database to SQL: https://data.cityofnewyork.us/api/views/6bzx-emuu/rows.json?accessType=DOWNLOAD

But the problem I have is that how can I insert the data in the appropriate table when the only thing that separates each data is just a comma.

Thanks

CheeseCube
  • 11
  • 3

1 Answers1

0

This will break the string into an array at the commas and trim whiteespace.

my_string = "blah, lots  ,  of ,  spaces, here "
[x.strip() for x in my_string.split(',')]

Then you loop through the array elements in Python and insert each in turn using a parameterized SQL statement. The idea is to do all the string-manipulation work in Python until you have a record ready to insert. then use Python to build and exeecute your SQL statement.

Sinthia V
  • 2,103
  • 2
  • 18
  • 36