Compare commits
2 Commits
eca2333521
...
a70f7aed34
Author | SHA1 | Date | |
---|---|---|---|
|
a70f7aed34 | ||
|
7d3e5bb9f9 |
BIN
data/Sanagro Product and Catagory list.xlsx
Normal file
BIN
data/Sanagro Product and Catagory list.xlsx
Normal file
Binary file not shown.
@ -4,7 +4,8 @@
|
||||
"description": "Nodejs data migration with excel, csv and rest apis.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "jest"
|
||||
"test": "jest",
|
||||
"start": "node src/index.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -24,6 +25,7 @@
|
||||
},
|
||||
"homepage": "https://github.com/CUBETIQ/data-migration-nodejs#readme",
|
||||
"dependencies": {
|
||||
"xlsx": "^0.16.9",
|
||||
"jest": "^26.6.3"
|
||||
}
|
||||
}
|
||||
|
26
src/index.js
26
src/index.js
@ -1,16 +1,20 @@
|
||||
const file = require('fs')
|
||||
// const file = require('fs')
|
||||
|
||||
file.readFile('./data/people.csv', 'utf-8', (err, data) => {
|
||||
if (err) {
|
||||
console.error(err)
|
||||
return
|
||||
}
|
||||
// file.readFile('./data/people.csv', 'utf-8', (err, data) => {
|
||||
// if (err) {
|
||||
// console.error(err)
|
||||
// return
|
||||
// }
|
||||
|
||||
console.log(data)
|
||||
// console.log(data)
|
||||
|
||||
const rows = data.split(/\r?\n/);
|
||||
const header = rows[0].split(',').map(str => str.trim())
|
||||
console.log(header)
|
||||
// const rows = data.split(/\r?\n/);
|
||||
// const header = rows[0].split(',').map(str => str.trim())
|
||||
// console.log(header)
|
||||
|
||||
});
|
||||
// });
|
||||
|
||||
var XLSX = require('xlsx')
|
||||
var workbook = XLSX.readFile('./data/Sanagro Product and Catagory list.xlsx');
|
||||
var xlData = XLSX.utils.sheet_to_json(workbook.Sheets['Sheet2']);
|
||||
console.log(xlData);
|
Loading…
Reference in New Issue
Block a user