I downloaded the 2015 adverse drug events data from openfda and I want to run some analysis with python. I am a python newbie, but have become comfortable with the scikit-learn libraries, but I cannot seem to get the json decoding to work to even get started.

This is my basic script:

import json  
import zipfile  

d = None  
data = None  
with zipfile.ZipFile("./data/drug-event-Q4-0001-of-0013.json.zip", "r") as z:
   for filename in z.namelist():  
      print(filename)  
      with z.open(filename) as f:  
         data = f.read()  
         d = json.loads(data)  

I know this is a pretty basic question, but I have been searching and though I am able to find code snippets for gzip, I cannot find any for plain zip files.

closed as off-topic by fgregg, philshem Nov 28 '16 at 18:47

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question does not appear to be about open data within the scope defined in the help center." – fgregg, philshem
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    I suggest you remove this question here and take it to Stack Overflow - that site is for programming issues specifically. And you should show (part of) a file in the ZIP: are these valid JSON (did you verify that)? – Jan Doggen Nov 26 '16 at 16:27
  • Unfortunately I cannot delete this since I posted the answer, but please feel free to delete it. – h.das Nov 28 '16 at 18:56

For those who might get to this question and look for an answer, here is the link to my other post with the answer. https://stackoverflow.com/questions/40824807/reading-zipped-json-files

Not the answer you're looking for? Browse other questions tagged or ask your own question.