You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a streaming data pipeline for processing CSV files. I would like to use archiver to split large CSV files and combine the chunks as one zip archive for user convenience.
Is it possible to add an entry stream line by line? Currently I only methods to add a file, a string or a file stream. But adding a stream or adding a csv file line by line are rather similiar
exportconstmakeCsvStreamWrite=(header: Record<string,string>,rowLimit=1000)=>asyncfunction*(input: AsyncIterable<Record<string,string|number>>){letfileCounter=1;letrowCounter=0;letheaderWritten=false;constarchive=archiver("zip");conststringifier=stringify();conststringifiedInput=Readable.from(input).pipe(stringifier);forawait(constrowofstringifiedInput){rowCounter++;if(!headerWritten){constheaderRow=stringifySync([header]);archive.append(headerRow,{name: `file-${fileCounter}.csv`});headerWritten=false;}// I would like to append the file line by line....archive.append(row,{name: `file-${fileCounter}.csv`});if(rowCounter>=rowLimit){// Now I would like to start a new file.rowCounter=0;fileCounter++;headerWritten=false;}archive.finalize()}};
The text was updated successfully, but these errors were encountered:
I have a streaming data pipeline for processing CSV files. I would like to use archiver to split large CSV files and combine the chunks as one zip archive for user convenience.
Is it possible to add an entry stream line by line? Currently I only methods to add a file, a string or a file stream. But adding a stream or adding a csv file line by line are rather similiar
The text was updated successfully, but these errors were encountered: