Forum Discussion

Mu's avatar
Mu
Frequent Visitor
3 years ago
Solved

Attempting to Download Zipped Json File

I am trying to downlaoad a bulk data file from the EIA (https://www.eia.gov/opendata/bulk/PET.zip). I've been going through a few forums and have gotten this far. Copied this from https://sql1...
  • ppm1's avatar
    ppm1
    3 years ago

    Try this instead where each row is a complete JSON string and Json.Document is used to parse it. 

     

     

     

    let
        Source = Web.Contents("https://www.eia.gov/opendata/bulk/PET.zip"),
        Custom1 = UnzipContents(Source),
        Content = Custom1{0}[Content],
        #"Imported CSV" = Csv.Document(Content,null,{0},ExtraValues.Ignore,1252),
        #"Added Custom" = Table.AddColumn(#"Imported CSV", "Custom", each Json.Document([Column1])),
        #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Column1"}),
        #"Expanded Custom" = Table.ExpandRecordColumn(#"Removed Columns", "Custom", {"series_id", "name", "units", "f", "unitsshort", "description", "copyright", "source", "iso3166", "geography", "geography2", "start", "end", "last_updated", "data"}, {"series_id", "name", "units", "f", "unitsshort", "description", "copyright", "source", "iso3166", "geography", "geography2", "start", "end", "last_updated", "data"})
    in
        #"Expanded Custom"

     

     

    Pat