I have a folder of about a million JSON files and I wrote this to convert them quickly to CSV, but the formatting is not correct for the software I’m feeding them into.
Here’s the code I’m using:
Do[(Export["CSV_OUT_" <> FileBaseName@jsonlist[[i]] <> ".csv",
Import[jsonlist[[i]]]]),{i, 1, Length[jsonlist]}];
The result looks like this:
“”“from”" → {““address_city”” → ““MORGANVILLE””, ““address_country”” → ““UNITED STATES””, ““address_line1"” → ““123 TEST ST””, ““address_line2"” → ““STE 1"”, ““address_state”” → ““NJ””, ““address_zip”” → ““07751"”, ““company”” → “”””, ““name”” → ““ELENA CROSS””}” “”“id”” → ““sfm_c4kjaugl7u8psvqfatp0"”” “”“imb_code”" → ““897714123456789"”” “”“mail_date”" → “”“”" “”“mail_type”" → ““usps_first_class””" etc.
The correct results would look like this in CSV format:
from address_city,address_country,address_line1,address_line2,address_state,address_zip,company,name,id,imb_code,mail_date,mail_type,object,press_proof,size,target_delivery_date,to address_city,address_country,address_line1,address_line2,address_state,address_zip,company,name MORGANVILLE,UNITED STATES,123 TEST ST,STE 1,NJ,7751,ELENA CROSS,sfm_c4kjaugl7u8psvqfatp0,897714123456789,usps_first_class,
How can I export correctly formatted CSV files like the one above quickly?
sfm_c4kjaugl7u8psvqfatp0.json (803 Bytes)