dataset-examples icon indicating copy to clipboard operation
dataset-examples copied to clipboard

JSON_to_CSV_Converter

Open bngksgl opened this issue 8 years ago • 5 comments

Hi I am trying to convert json code into CSV and I am using the code that you have provided, however I am running into some errors. When I write the $ python json_to_csv_converter.py yelp_academic_dataset.json in the commandline i am getting the following error:

Traceback (most recent call last): File "json_to_csv_converter.py", line 122, in column_names=get_superset_of_column_names_from_file<json_file> File "json_to_csv_converter.py", line 25, in get_superset_of_column_names_from_file for line in fin: File "C:\Users\Bengi\Appdata\Local\Programs\Python\Python35-32\lib\encodings\cp1252.py" line 23, in decode return codecs.charmap_decode(input, self_errors,decoding_table)[0] Unicode Decode Error: 'charmap' codec cant decode byte 0X9d in position 1102: character maps to

Can you help me please?

bngksgl avatar Feb 27 '16 23:02 bngksgl

@bngksgl, or anyone else, if you're seeing json DecodeErrors, it may be that the input file is not a valid json file. The Yelp dataset is delivered as a compressed archive, .tar and is, 'double-zipped'. Before running the converter script you should see 5 separate json files (business,json, review.json etc...). In Windows, after unzipping yelp_dataset_challenge_academic_dataset.tar, I had to add the .tar extension again to the ~2GB output file, and unzip that to get the individual files... Then, converting the individual json files worked fine. I ran into a similar error, not realizing the file hadn't been completely unpacked.

capture

russ-white avatar Apr 14 '16 01:04 russ-white

I faced the same issue while downloading the dataset on MAC. It is a double zipped file. Thank you @russ-white for the resolution!!

RashmiGautam avatar Jul 07 '16 16:07 RashmiGautam

Thank you @russ-white for the explanation!

ydeng11 avatar Oct 22 '16 03:10 ydeng11

Yes, thanks from me as well

RohitJain13 avatar Nov 11 '16 18:11 RohitJain13

You saved a lot of time man! @russ-white

Batuu13 avatar Dec 08 '16 18:12 Batuu13