Replies: 2 comments
-
I think I've got it figured out, posting my solution here in case anyone comes across similar needs. I confused the Here I used async function getPipeline(zipPath, fileName) {
const zip = await yauzl.open(zipPath);
try {
for await (const entry of zip) {
if (entry.filename === fileName) {
const readStream = await entry.openReadStream();
console.log(fileName, 'selected')
const pipeline = new chain([
readStream,
parser(),
streamArray(),
data => {
// Use data
}
]);
return pipeline;
}
}
} catch (err) {
console.error('Error processing ZIP file:', err);
}
return null;
}
// const pipeline = await getPipeline(zipPath, fileName);
// pipeline.on( ... I also wondered if the zip itself can be streamed, but it turns out there are complications with the ZIP archive format and it may result in corrupted data according to the |
Beta Was this translation helpful? Give feedback.
-
Unless I am dealing with unzip -p data.zip datum1.json | node my-json-utility.js If your utility assumes that a JSON file is read from |
Beta Was this translation helpful? Give feedback.
-
Hello, thank you for this library. I have a particular use case where I have a zip file that contains different JSON files (labeled in order) that may need to be read. I have attached a sample zip file with 2 of such JSON files inside.
I am wondering if the following can be done via a chain:
For the above two, I actually only need the object with a particular key value. I have the following code that does this (e.g. get the index 9 object in the JSON file) with an unzipped file:
So I am wondering how I can do this on a zipped file scenario. Thank you!
term_bank.zip
Beta Was this translation helpful? Give feedback.
All reactions