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
Hello there, I am trying to use this package to handle potentially large csv files, but I got an error.
I will try to show the code to see where I might be doing something wrong.
The file that I'm trying to upload is this:
the middleware for upload the files is express-fileupload
Example app.ts
// ... skipped for brevityapp.use(fileUpload());// ... skipped for brevity
This service has the logic to handle the file using express-fileupload:
asyncprocessFile(files: IUpload.IFileArray|undefined,config: any){console.log('FILES:',files);// 1. VALIDATE INPUT:if(!files||Object.keys(files).length===0){thrownewError('No files were uploaded.');}if(!this.util.is.object(files.dataset)){thrownewError('Invalid dataset.');}if(this.util.is.empty(config)){thrownewError('Invalid configuration.');}if(!this.util.is.string(config.provider)||this.util.is.empty(config.provider)){thrownewError('Invalid provider.');}if(!this.util.is.string(config.columns)||this.util.is.empty(config.columns)){thrownewError('Invalid columns.');}letnullObject: boolean=false;if('nullObject'inconfig){if(!this.util.is.boolean(config.nullObject)){thrownewError('nullObject must be of boolean type');}else{nullObject=config.nullObject;}}letdelimiter: string[]=[','];if('delimiter'inconfig){if(!this.util.is.array(config.delimiter)||config.delimiter.length===0){thrownewError('delimiter must be of array type');}else{delimiter=config.delimiter;}}letquote: string='"';if('quote'inconfig){if(!this.util.is.string(config.quote)||config.quote===''){thrownewError('quote must be of string type');}else{quote=config.quote;}}lettrim: boolean=true;if('trim'inconfig){if(!this.util.is.boolean(config.trim)){thrownewError('trim must be of boolean type');}else{trim=config.trim;}}letignoreEmpty: boolean=false;if('ignoreEmpty'inconfig){if(!this.util.is.boolean(config.ignoreEmpty)){thrownewError('ignoreEmpty must be of boolean type');}else{ignoreEmpty=config.ignoreEmpty;}}letnoheader: boolean=false;if('noheader'inconfig){if(!this.util.is.boolean(config.noheader)){thrownewError('noheader must be of boolean type');}else{noheader=config.noheader;}}// 2. PARSE DATA:letdata: any[]=[];try{constdataset=(files.datasetasIUpload.IUploadedFile);data=awaitthis.util.csv({nullObject: nullObject,delimiter: delimiter,quote: quote,trim: trim,ignoreEmpty: ignoreEmpty,noheader: noheader,includeColumns: newRegExp(config.columns.replace(/,/gm,'|')),headers: config.columns.split(','),}).fromString(dataset.data.toString('utf8'));}catch(err){console.log('ERROR ->',err);thrownewError('Cannot parse the csv file content. '+err.message);}if(data.length===0){thrownewError('Cannot save the provider data being empty.');}// 3. INSERT DATA:returnawaitthis.repository.createProducts(config.provider,data);}
And this is how I upload the file (curl for testing purposes) and the error I got:
The text was updated successfully, but these errors were encountered:
Hi, I'm going to close this because it is not an issue, I was trying to parse big files in the wrong way, the solution is to use streams and it's working like a charm with file of more than 7GB (smooth).
Hello there, I am trying to use this package to handle potentially large csv files, but I got an error.
I will try to show the code to see where I might be doing something wrong.
The file that I'm trying to upload is this:
![Screen Shot 2020-02-18 at 2 32 42 PM](https://user-images.githubusercontent.com/2402579/74775701-e1156a00-525b-11ea-9537-8630eab414bc.png)
the middleware for upload the files is
express-fileupload
Example
app.ts
This service has the logic to handle the file
using express-fileupload
:And this is how I upload the file (
curl
for testing purposes) and the error I got:The text was updated successfully, but these errors were encountered: