0

data file looks like the below. Note that the tags and values are not necesirly fixed (i.e. one file may have 10, next 30, 31 etc)

{
        1=6487490
        2=905629
        3=14959 
        4=85
        7=1
        8=
        9=
        16=1
        20=1252903800
        21=557
        22=13
}

i want output like this using python2

1, 2, 3,4,5,8,9,16,20,21,22
6487490,905629,14959,85,1,,,1,1252903800,557,13

where all the tags and values are converted to the csv structure.

jq170727
  • 13,159
  • 3
  • 46
  • 56
J.J
  • 3
  • 2
  • Have a look at: https://stackoverflow.com/questions/1871524/how-can-i-convert-json-to-csv – Sergiu Oct 15 '17 at 09:32
  • Thanks Sergui: i am getting this error when i try that option. File "C:\Python\Python27\lib\json\decoder.py", line 380, in raw_decode obj, end = self.scan_once(s, idx) ValueError: Expecting property name: line 2 column 9 (char 10) i.e. 1=6487490 something is not as expected, when i use import json with open("small_ds.json") as file: data = json.load(file) – J.J Oct 15 '17 at 10:33

0 Answers0