How to upload and parse a CSV file using NestJs & Multer

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Hello friends welcome back to the new tutorial of the nestjs today we are going to learn how to read and uploaded CSV file using nest chers and the malta those who haven't subscribed my channel yet please do subscribe my channel and if you like the video please do like share and comment on my video so let's get started first of all if you haven't seen my previous videos then you have to look out my previous video for how about the malta okay so I will let you know about exactly what extensions we have to inst stall all the packages give me a second so this is the file uploaded code for before one okay so this is we have to for the malter we have to use the malter platform Express then here one more thing we have to add that is CSV parer okay so these modules you have to install Okay after this we have to go with our file module. where we have to do the file multer configuration so here we in the Imports multer module register destination that should be uploads controller that is file controllers right so first we have to create the file module. in the source directory and here we have done the where we have to upload the files okay that is we have to upload the CSV file then we have to read right so first upload code over here so upload the CSV file okay then we have to go with the files controller where we have add the logic okay so here we have the interceptors upload file in the next CHS common this is basically The Decorator for uploading the files okay so here I'm using the CSV parser for parsing the CSV so whatever data we have in that we have to look into it okay so this is this is the files and the upload so file SL upload this is our rest API path Okay then if the FI if there is no file then there should be a no file uploaded else what we are going to do is we are going to make a result at array should be empty and then we are going to read the file after reading the file whatever data we are getting then we can pass the data you can just print the data over here here you can perform the operations on the pass CSV for example save it to the database or perform some data processing you can do that part over here okay so first we check that whatever data we have uploaded we have successfully passed or not right so create read stream read the uploaded file as a stream and pass it as a CSV right so let's see the data is passed or not and the last what we have to do if you want to unlink the uploaded file then you can use FS unlink the file path okay you can also do that at the last file upload is processed and uploaded successfully right and the last app module. TS where we have to import the file module file module Imports file module okay these three files required let's try to upload the CSV file and check how we can pass the CSV data right so let's go to the postman this is our route files upload so let's pass any CSV file so I have already file that is in the home okay I think they don't have the permissions okay so I need to put let me upload the files so here in the which location is is in the recent documents okay let me add this in the document so here we have a data. CSV and let's moved into the documents okay so let me paste this over here data. CSV let's try to upload that one okay so here we have the documents here we have a data. CSV let's try to upload this file and we have to check that one it is uploaded in the data. CSV or not send it file uploaded let's check in the upload section of the HTML where we have a nest project file upload app and here we have the upload section and here you can see that the CSV file is uploaded right so let's check it out whether the files we have passed the data or not so here you can see that name John email age name John email so all the three records have been F successfully I will open that CSP file so here this is a CSV file okay the name email and the age John do James Smith and Alice right so this is successfully we have uploaded and successfully pass the data right any doubt any query in that do let me know in the comment section thank you so much for watching this video have a great day
Info
Channel: Technical Rajni
Views: 1,269
Rating: undefined out of 5
Keywords: file upload, how to upload and read a file with nodejs / express, upload files to s3 using angular and nestjs, upload files to aws s3 using nestjs and typescript, node js file upload, nestjs file upload, node.js: upload csv file data to database, how to upload file using node js, upload files to s3 using nestjs, export mysql data to csv file using node, upload file to s3 using nestjs application, upload csv file to node.js server with fetch api, nestjs file download
Id: 1Y73flyDFOY
Channel Id: undefined
Length: 4min 49sec (289 seconds)
Published: Mon Dec 25 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.