1

I have a JSON file which needs to essentially perform an action similar to a cross apply in SQL by unpacking a list.

I'm currently using json_normalize, however, this does not work with lists so I am looking for a way to flatten out the list column.

How I do it in SQL:

CROSS APPLY (SELECT value from STRING_SPLIT(x.list, ',')

Current Output in Python:

id,name,list
1,tom,[2,4,6]

Expected Output in Python:

id,name,list
1,tom,2
1,tom,4
1,tom,6

Any advice will be appreciated.

jcoke
  • 1,555
  • 1
  • 13
  • 27

0 Answers0