0

I need to extract data out of json to a csv file. working with csv / excel in python is a breeze but I never handled json data.

I know that there is a json lib for python but the documentation isn't so helpful.

This is an example of a json file :

{"properties": 
    {
        "$initial_referring_domain": "$direct", 
        "$screen_height": 1080, 
        "$city": "Melbourne", 
        "$initial_referrer": "$direct", 
        "$screen_width": 1920, 
        "mp_country_code": "AU", 
        "$region": "Victoria", 
    }, 
    "distinct_id": "151", 
    "sampling_factor": 133, 
    "name": "login", 
    "time": 53000
}

I need to separate my files, one to include only the properties and the other for all the rest.

I'm not looking for a whole solution (not that I mind) but rather to get some guidance to understand how to solve it by myself.

Thanks !

Y. Eliash
  • 1,808
  • 3
  • 14
  • 23
  • After you load file by `o = json.load(file_obj)` everything from JSON file is (nested) python object. You may access dictionary fields with `d['key']` syntax, index lists with `l[index]` syntax. What's unclear here? – Łukasz Rogalski Mar 23 '16 at 13:50
  • @Rogalski , I tried to loop the keys but I get an error that my dict. isn't iterable. – Y. Eliash Mar 23 '16 at 18:31

0 Answers0