Тёмный

Generate CSV and Download it Client Side from the Browser 

optikalefx
Подписаться 11 тыс.
Просмотров 53 тыс.
50% 1

Sometimes you need to give people the ability to export CSVs. And sometimes you have all the data already in your react/angular/ember/polymer/vue app. In this case, you can use this technique to avoid making a trip to your server to generate a report for data you already have.

Наука

Опубликовано:

 

4 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 94   
@alinsimion
@alinsimion 4 года назад
I searched so much on Google for a good tutorial and I've finally found it! Thank you!
@pooterist
@pooterist 4 года назад
Excellent. I was looking all over for something like this. You've made my day
@alokranjan476
@alokranjan476 4 года назад
Like others, I also searched it a lot in Google but didn't find it properly until I come here. It's perfect and to the point. Thanks a lot
@rikkon6928
@rikkon6928 2 года назад
This is exactly what i was looking for. Super helpful and well explained. Thank you!
@bdnoobsingers3094
@bdnoobsingers3094 3 года назад
Mind Blowing and perfectly error handled. Thank you a lot for making this tutorial. Looking for more amazing technology...
@kinjalbasu9220
@kinjalbasu9220 4 года назад
Thank you so much brother, you made my day. I have been looking for a direct tutorial like this for weeks. But all I get is convoluted code without adequate explanation. RU-vid needs more content like this...but I guess it is not catchy enough to get into my recommended by the algorithm... :( :( Please keep up the good work...
@transcendentalmess
@transcendentalmess 5 лет назад
Super clear video and very helpful. Nicely done!
@karlkrasnowsky3895
@karlkrasnowsky3895 5 лет назад
Good job! Just what I was looking for. Forgot about the escaping thing.
@marcocacone
@marcocacone 4 года назад
Really well explained! Good job, what I was looking for!
@willigeek2013
@willigeek2013 4 года назад
Bruh! You're the OG of Javascript. Thanks for the help.
@davidkiprono
@davidkiprono 5 лет назад
Your explanation is really good, thank you so much
@Emekaelo
@Emekaelo 3 года назад
Awesome! Thanks At 5:36, no need to 'assume' it's an array. It's definitely an array being passed in because map returns an array.
@bobdpa
@bobdpa 4 года назад
Lots of great info here. Nicely done! 🤓
@balakrishnanyukesh1646
@balakrishnanyukesh1646 3 года назад
Excellent Tutorial Sir. Clearly Explained. I have learnt a lot. Thank you so much :)
@vladahinski5699
@vladahinski5699 4 года назад
Thank you so much!! Have a great year!
@akshaysharma8038
@akshaysharma8038 4 года назад
Thanks for such a great explanation 🙌🙌
@rupmou
@rupmou 2 года назад
You Sir, are the mastermind. Awesome
@suryaningmentari668
@suryaningmentari668 Год назад
Thankyou so much, found many great info here 🤩
@lucanunziata5392
@lucanunziata5392 4 года назад
Thank you so much! great explanation
@bijay7
@bijay7 4 года назад
dude you are super awesome ❤. This video is a life saver. Thanks a lot
@hashanhemachandra4832
@hashanhemachandra4832 Год назад
Thanks man! You saved me tons of time!
@hometowndeveloper
@hometowndeveloper 4 года назад
you are my hero, thank you so much!
@heliojr
@heliojr 5 лет назад
This is awesome! Thank you.
@AbhishekGuptaabhisaa
@AbhishekGuptaabhisaa 5 лет назад
Thank you so much, it was really helpful. :-)
@lokeshkharve5126
@lokeshkharve5126 2 года назад
Good job, it's really very help full 👍❤
@planetmall2
@planetmall2 5 лет назад
Thank you for this video!
@suhelrose1
@suhelrose1 5 лет назад
Super video , It is very helpfull.
@adeelmalik2848
@adeelmalik2848 5 лет назад
This is awesome! thanks
@mudyeet_
@mudyeet_ 3 года назад
Sick! I was looking for a library to do it for me but I guess I don't need it anymore, thanks!
@ankitagarwal4914
@ankitagarwal4914 5 лет назад
Perfect! You are awesome
@softwaremamma861
@softwaremamma861 3 года назад
a very useful tutorial
@muhdkbn6456
@muhdkbn6456 3 года назад
Life saver . Thanks
@freedoom4090
@freedoom4090 2 года назад
wow! very good. thanks!
@eduardobaas3331
@eduardobaas3331 5 лет назад
great video!!
@pbaskoro70
@pbaskoro70 2 года назад
nice video, its working
@rodrigossoaress
@rodrigossoaress 5 лет назад
wonderfull, it helped a lot
@xiomaraandreapulido2089
@xiomaraandreapulido2089 5 лет назад
Gracias ingeniero.
@AjithKumarsham
@AjithKumarsham 4 года назад
you're a rockstar
@castro_hassler
@castro_hassler 5 лет назад
You're awesome!
@mehniyarif2
@mehniyarif2 3 года назад
Allah razı olsun kardeşim
@pavanrao2965
@pavanrao2965 4 года назад
This video was exactly what i was looking for. Thats great. Is there anyway how we can style the elements as well?
@haroldrmendoza
@haroldrmendoza 4 года назад
Thank You so much!
@chommhee
@chommhee 2 года назад
thank you, bro.
@jigumany
@jigumany 4 года назад
thank you!
@jondyason336
@jondyason336 5 лет назад
thanks a lot!
@sarthinigam3584
@sarthinigam3584 3 года назад
Hey. Great video. I do have a question though. How would i access the data had for eg the column "age" been an array as well?
@kervinsilaire1586
@kervinsilaire1586 4 года назад
Thank you.
@raphaelremigio1405
@raphaelremigio1405 4 года назад
Perfect! how do i replace the fictitious data from the json generator with data from my database, converting it into a json file? Sorry, I'm a beginner in NODE JS I use the MongoDB database
@alicecroydon2417
@alicecroydon2417 4 года назад
2:11 yes you are right that is stupid. Liked and subscribed.
@togoenvogue
@togoenvogue 4 года назад
Excellent job. This tutorial is still relevant and up to date. Can anyone please show how to convert back the csv file generated from this tutorial into a JSON data I can send into a database? Thank you
@mreddygi
@mreddygi 3 года назад
thanks a lot
@deepakkumar-rz7ff
@deepakkumar-rz7ff 3 года назад
Thanks for the video. I used your code in my flask app to download csv from html table . The only place where i am stuck is like I want my csv's to be downloaded with a different name each time according to my input.Any help in this direction will be appreciated
@vizunaldth
@vizunaldth 3 года назад
Nice!
@petaca39
@petaca39 2 года назад
Good video consultation and if from the client you want for example to send data to the server for example the latitude and longitude and save it in a data.csv file, how would the code have some reference link?
@user-oc8tu9pl3k
@user-oc8tu9pl3k 5 лет назад
is there a way to convert csv to json on the client side?
@vijaydadhich3358
@vijaydadhich3358 4 года назад
If a value is an object like {details: {address: 'house no. 25, "Market" etc.'}} then what is the soluction currently showing object value showing as [object object]?
@akhileshsaini1961
@akhileshsaini1961 4 года назад
Can we implement this in polymer js ???
@number3boo
@number3boo 3 года назад
17:08 nice solution :)
@rohitbassi1769
@rohitbassi1769 3 года назад
is there a way to check, if the download csv function fails? or how to check that download was successful- that download was complete on client side?
@RamKumar-hg6ej
@RamKumar-hg6ej 4 года назад
How to add new line inside cell ?
@dustinpatterson3534
@dustinpatterson3534 5 лет назад
Great video! Do you have your code posted on github? That would be helpful.
@RaffaCaboFrio
@RaffaCaboFrio 4 года назад
objectToCSV (data) { // TODO: move to a lib. global plugin or mixin. const csvRows = [] // get headers const headers = Object.keys(data[0]) csvRows.push(headers.join(',')) // loop over values for (const row of data) { const values = headers.map(header => { const escaped = ('' + row[header]).replace(/"/g, '\\"') return `"${escaped}"` }) csvRows.push(values.join(',')) } // join and return all lines return csvRows.join(' ') }
@viratsuresh5946
@viratsuresh5946 2 года назад
How do we generate a groovy document with groovy syntax via angular
@cgtdj
@cgtdj 4 года назад
Please post the code in your description...it becomes useful for users
@achyutrastogi8080
@achyutrastogi8080 3 года назад
Hey, can you post a link to this code in the description? It would be very useful.
@anithaekambaram7512
@anithaekambaram7512 4 года назад
how do i change this to excel for windows
@boryana65
@boryana65 5 лет назад
Hello, how you are able to use objectToCSV ? Is there some library ? Thanks
@haris1558ssss
@haris1558ssss 5 лет назад
Great video. But I do however have the same question as an absolute beginner.
@haris1558ssss
@haris1558ssss 5 лет назад
Just figured, the function objectToCSV isn't an imported library but is written inside the function. He just writes it after calling it, around 4:22
@Walseloc11
@Walseloc11 3 года назад
I tried doing this a while back and couldn't figure it out. This should work!! I do have one question though. The API I'm getting my information from requires a token. How would I add the token to this code?
@optikalefx
@optikalefx 3 года назад
You can pass tons of stuff to fetch. Including custom headers, which is where you'd put a token.
@pratikswvk
@pratikswvk 3 года назад
Thanks so much. I am getting the CSV file but all the data is in single column on different rows with header and content having comma and quotes in it.. the data is not present in seperate cells like we see at the end of video. Can anyone please help me on this issue or post the code.
@najacidani11
@najacidani11 3 года назад
Hey, I know it was long time ago,but do you remember how did you solve the problem? Because i have same issue.
@EduardoHernandez-ux6gg
@EduardoHernandez-ux6gg 3 года назад
why use parameter charset=utf-8 ??
@JimCraft123
@JimCraft123 5 лет назад
what if the json file look like this? { "Data1": ["","","",""], "Data2": ["","","",""] } all I want to parse into csv is DATA1 only, how can i manage to do it?
@optikalefx
@optikalefx 5 лет назад
a CSV needs headers - your Data1 does not have any headers. What would you expect them to be in this example?
@JimCraft123
@JimCraft123 5 лет назад
@@optikalefx umm I mean if data1 and data2 are totally different data, for example Data1 is producers Only shows the name Data2 is product It shows every single one product data with Id, price, cate, cateId
@suprajajampala2439
@suprajajampala2439 10 месяцев назад
How to create multiple sheets in one csv file with this approach?
@GmodArgentina
@GmodArgentina 2 года назад
Yo dude, how did you map and object and not get an error
@VinhPham-hz8ny
@VinhPham-hz8ny 2 года назад
Thank you for the tutorial, your way of explaining it a bit of unorganized, lot of mumble jumbo and repeating yourself. Just want to give an honest feedback, keep making more tutorial. Thanks again.
@Aarshyboy96
@Aarshyboy96 6 лет назад
what mac finder are you using?
@optikalefx
@optikalefx 6 лет назад
Pathfinder
@sgomezj_
@sgomezj_ 5 лет назад
I don't understand that for, the row[values] .. :/
@optikalefx
@optikalefx 5 лет назад
which part? Happy to explain it more.
@sgomezj_
@sgomezj_ 5 лет назад
@@optikalefx Is the row the actual row? That constant that you declare what is it? Why when you make the return row[header] it returns every row in the desire position, sorry if I'm not clear explaining myself, I'm new at js, that function is pretty abstract for me 😜
@optikalefx
@optikalefx 5 лет назад
@@sgomezj_ so in that loop, row is indeed each row of data. Then we're looping over the headers. Finally we are accessing the row object by each header. The reason we're doing this is to ensure that we get an Object that has the same number of keys in the same order. We can't trust the order of keys in an object to always be the same, but by looping over the headers array (where arrays do have guaranteed order) we can ensure the order of keys in the row object. This is important for a CSV so that the columns line up with the headers.
@sgomezj_
@sgomezj_ 5 лет назад
@@optikalefx Nice, thank you. I understood, so the rows have a default key which turns out to be the same of the headers, and that's why we can map over the headers array?
@optikalefx
@optikalefx 5 лет назад
@@sgomezj_ It's not that it 'happens' to be that way. On line 10, we are getting the headers from the first row. So we're basically saying "whatever the keys of that first object are, let's make sure the rest of that object matches"
@liftme8468
@liftme8468 2 года назад
provide code link
@someshmusunuri4233
@someshmusunuri4233 Год назад
Hands down the best thing to unblock me.
Далее
Web Scraping with Puppeteer, NodeJS & Shopify
27:54
Просмотров 66 тыс.
Get objects from Amazon S3 using NodeJS
7:37
Просмотров 65 тыс.
JSON and AJAX Tutorial: With Real Examples
40:45
Просмотров 1,8 млн
JavaScript FileReader
15:08
Просмотров 137 тыс.
NodeJS Hubspot API Basics (Owners & Deals API)
17:34
Просмотров 27 тыс.
All 29 Next.js Mistakes Beginners Make
1:45:10
Просмотров 99 тыс.
Drag and Drop is EASY with SvelteJS
39:35
Просмотров 2,5 тыс.
Why The Windows Phone Failed
24:08
Просмотров 177 тыс.
Новые iPhone 16 и 16 Pro Max
0:42
Просмотров 2,3 млн
КАКОЙ SAMSUNG КУПИТЬ В 2024 ГОДУ
14:59