Тёмный

How to convert csv to json with simple javascript / convert csv to json without npm package 

Azhar Techno Coder
Подписаться 3,6 тыс.
Просмотров 3,7 тыс.
50% 1

How to convert csv to json with simple javascript / convert csv to json without npm package
Code:
Program:
const fs = require('fs')
csvfile = fs.readFileSync('./csvFile.csv')
const arr = csvfile.toString().split("
")
//console.log(arr)
var jsonObject = [];
var headers = arr[0].split(',')
//console.log(headers);
for(var i=1;i arr.length;i++){
var data = arr[i].split(',');
var object = {};
for(var j=0;j data.length;j++){
object[headers[j].trim()] = data[j].trim();
}
jsonObject.push(object)
}
console.log((jsonObject))
CSV File:
fname,lname,sno,phone,address
a,b,1,234,india
c,d,2,456,india
e,f,3,789,india
Chapters:
0:00 - Introduction of the video
0:53 - Program for converting csv to json with simple javascript
7:30 - Execution of the program
8:03 - End Tags and subscription to channel
Donation Section:
Now you can Donate us via Paypal or Google Pay
Paypal link : www.paypal.me/Azhar67
GooglePay/PhonePe/BHIM App UPI ID : shaikazharjamal@okhdfcbank
My second Channel:
WrestleTalkByAzhar - / wrestletalkbyazhar
Next Steps :
---------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------
Must Watch Playlists
► 1. Javascript - • Javascript Factory
► 2. Puppetter - • Puppeteer
► 3. Cypress - • Cypress
► 4. Tech works - • Video
► 5. Vbscript Basics To Advanced - • VBScript Part 1 - Fea...
► 6. Jmeter - • Jmeter Tutorials
► 7. Excel - • Videos On Excel
► 8. Appium - • Appium
► 9. Shares - • Shares
► 10. Javascript Interview Questions - • Javascript Interview Q...
► 11. C# Tutorials - • C# Factory
► 12. HTML & CSS - • HTML & CSS
► 13. Browser Console - • Browser Console
► 14. JSON - • Videos on Json
► 15. Specflow - • Specflow Tutorials
---------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------
#convertcsvtojson
#javascript
#csvtojson

Наука

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

 

20 июл 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 5   
@rodrigoribeiro8700
@rodrigoribeiro8700 3 месяца назад
Very nice, thanks!
@rshahinbegum5908
@rshahinbegum5908 Год назад
Superb 👍
@farazbrf8627
@farazbrf8627 Год назад
❤️❤️❤️❤️
@Laxami790
@Laxami790 Год назад
It show error '' cannot read properties of undefined (reading 'trim')''
@AzharTechnoCoder
@AzharTechnoCoder Год назад
Hey make sure the csvFile is present inside your folder itself. if not please create the file and add the contents given in the description
Далее
вот тебе и бэйбик👴🏻
01:00
Просмотров 323 тыс.
Каха бизнес-класс
00:48
Просмотров 1,1 млн
Convert CSV to JSON using PHP
13:01
Просмотров 5 тыс.
Learn JSON in 10 Minutes
12:00
Просмотров 3,1 млн
Parsing a CSV file with JavaScript
21:21
Просмотров 6 тыс.
Лучшие кожаные чехлы для iPhone
1:00