Skip to content

Support for gz zip files (feature request) #351

Description

@jhelvy

Hi! Loving this packing!

I wanted to ask if support for gz files could be added. Right now if I use the zip_to_disk.frame() function on a .gz file I get an error. Here's a simple example:

> library(disk.frame)
> write.csv(mtcars, "mtcars.csv") # Create csv
> system("gzip mtcars.csv") # Zip it to .gz file
> df <- zip_to_disk.frame("mtcars.csv.gz") # Attempt to read .gz file to disk.frame

This produces this error:

Error in unzip(zipfile, list = TRUE) : 
  zip file 'mtcars.csv.gz' cannot be opened

My solution for now is to use {vroom} to read in the .gz and then convert it to a disk.frame:

library(vroom)
df <- as.disk.frame(vroom("mtcars.csv.gz"))

It works just fine, but I have a file with several hundred .gz files so it'd be nicer if I could just point to the folder and have {disk.frame} read them in sequentially.

Activity

  1. xiaodaigh commented on Sep 7, 2021

    @xiaodaigh
    Collaborator

    I see. For now I think this would work

    list_of_disk.frames = lapply(files, function(file) {
      as.disk.frame(vroom(file))
    })
    
    
    fnl_disk.frame = rbindlist.disk.frame(list_of_disk.frames)
    
  2. jhelvy commented on Sep 7, 2021

    @jhelvy
    Author

    Oh nice work around! I didn't even know about rbindlist.disk.frame().
    This should work as a generic solution too for lots of different file types.

  3. xiaodaigh commented on Sep 7, 2021

    @xiaodaigh
    Collaborator

    Yep. The only think I would say is that you can parallelize the lapply using future.apply

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions