Read Gzip file as dataframe

All,
I have an excel file that is returned as a html/text content when I query an API endpoint.

image

I am successfully able to write the data to an Excel File using writeBin function. However, I would like to try and extract it into a data frame, make some edits and then encode it back before writing out the same file in the same format. Wondering how I can do that.

Best
Uday

You should have a look at ?connections where you have a gzfile connection to read such file and extract the content.

The :package: R.utils has a nice wrapper function called gunzip to help decompress some *.gz file.

Once you have extracted to excel, you can manipulate the file (with openxlsx or readxl).

Then you can recompress it if you want (using R.utils::gzip)

1 Like