Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ZIP file attachments. #222

Merged
merged 6 commits into from
Jun 2, 2021
Merged

Add support for ZIP file attachments. #222

merged 6 commits into from
Jun 2, 2021

Conversation

mbostock
Copy link
Member

@mbostock mbostock commented Jun 2, 2021

Adds fileAttachment.zip which returns a promise to a ZipArchive. The ZipArchive exposes an archive.fileNames() method which returns the array of file names, and an archive.file(name) method which returns a FileAttachment-like object. So, to load a CSV file in a ZIP file, you can now say:

archive = FileAttachment("ACS_14_5YR_B01003.zip").zip()
data = archive.file("ACS_14_5YR_B01003_with_ann.csv").csv({typed: true})

As with XLSX #215, I’ve decided not to expose JSZip as a recommended library, and instead wrap it with a more minimal abstraction that feels more Observable-ish.

Screen Shot 2021-06-01 at 6 47 28 PM

@mbostock mbostock requested a review from visnup June 2, 2021 01:50
Copy link
Member

@visnup visnup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume for archives with directories, the filenames array will contain values like "dir/file.csv"? and only contain files and not "dir/"?

now thinking we could use a .tarball version.

@mbostock
Copy link
Member Author

mbostock commented Jun 2, 2021

I assume for archives with directories, the filenames array will contain values like "dir/file.csv"? and only contain files and not "dir/"?

Good catch. It did include directories, but now I’ve filtered them out.

@mbostock mbostock merged commit 9a8e809 into main Jun 2, 2021
@mbostock mbostock deleted the mbostock/zip branch June 2, 2021 21:13
@mbostock mbostock mentioned this pull request Aug 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants