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():  
      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.

  • 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)?
    – user4293
    Nov 26, 2016 at 16:27
  • Unfortunately I cannot delete this since I posted the answer, but please feel free to delete it.
    – h.das
    Nov 28, 2016 at 18:56

1 Answer 1


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.