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"" -> {""addresscity"" -> ""MORGANVILLE"", ""addresscountry"" -> ""UNITED STATES"", ""addressline1"" -> ""123 TEST ST"", ""addressline2"" -> ""STE 1"", ""addressstate"" -> ""NJ"", ""addresszip"" -> ""07751"", ""company"" -> """", ""name"" -> ""ELENA CROSS""}" """id"" -> ""sfmc4kjaugl7u8psvqfatp0""" """imbcode"" -> ""897714123456789""" """maildate"" -> """"" """mailtype"" -> ""uspsfirstclass""" etc.
The correct results would look like this in CSV format:
from addresscity,addresscountry,addressline1,addressline2,addressstate,addresszip,company,name,id,imbcode,maildate,mailtype,object,pressproof,size,targetdeliverydate,,to addresscity,addresscountry,addressline1,addressline2,addressstate,addresszip,company,name MORGANVILLE,UNITED STATES,123 TEST ST,STE 1,NJ,7751,,ELENA CROSS,sfmc4kjaugl7u8psvqfatp0,897714123456789,,uspsfirst_class,
How can I export correctly formatted CSV files like the one above quickly?
Attachments: