From 7d3e5bb9f9e4cc2dbaf95f48ade33c6aff968e9d Mon Sep 17 00:00:00 2001 From: Hou Samnang Date: Fri, 26 Mar 2021 13:26:14 +0700 Subject: [PATCH] xlsx import data --- data/Sanagro Product and Catagory list.xlsx | Bin 0 -> 13417 bytes package.json | 8 ++++-- src/index.js | 26 +++++++++++--------- 3 files changed, 21 insertions(+), 13 deletions(-) create mode 100644 data/Sanagro Product and Catagory list.xlsx diff --git a/data/Sanagro Product and Catagory list.xlsx b/data/Sanagro Product and Catagory list.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..12f75752027e42faf7f575603f4fc1c18244e742 GIT binary patch literal 13417 zcmeHuWmsHE(>6hZ1b3IaF}4h2^yS1-hn*3+0E|z z{rP^r&v0FHhU%(&x~uN$?sK|ENfrVU9qc(63>X*~37C&<3Z~UFFt86$U|?uqFyOkP z4)(6*_O6C%o{r`&`V6n_Y>9Ir!KprgfrIq_`}#lZfsuq2>rYJReMivVq49t(Vgyml z|%*C|!A6XV4&FosMuK#vqJnso1B-(@0e%}z*dj0F{>4h2g{ zcpmu_Z>tD@w)O$dY%s)kX z$*;H)Pv&9-!BmN`+7e@o%D715PcpN$Q&C1`-VH;Q<0n>2Dd@pw2{k2BMuDC;?x9GStx7 z+}4GW;qm>ynfZS>9se@)@_2d09wzvZBdOcafy90r)(RpNe zOI?)s$ZEJj5R(2Kez!w_CBEpr0g{VvY~_)t=)9zj9u*Dl7pHbXr z&Sx%CC1pIR+&f}u%9@LFWCvGBC8kcqYLLenG;v|k3h+ZP`BUHM^vP>4n_N{sn-Nhx zs0gWU;{34pemvcOE~#)AK`@M4ZhtZrW5C74VxiJ!z?S6v8dqJ_lH01{kS!VGkr%v z9YJ4wo#O4y6L>nJgsXHf!6=l!O?>7^x}bCrd@tH6G{}&H6-0LHD>zYfw^nrY8SA-q zrg|(nHB5a$nGS&JimO9_FNk=yaWb>6*hnZ))XBfezemC4R;=)xEH{E2DrDg(KY!Aw zirR_LE@PVEEX@=Lch}8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9vgP zQGP!l{)JKrx+nWjP3K=xo{o!uNBR9g^B0O3=D(sm9dG`Q^7{?pFBBQ_CzOBO9{!H- z`>y*J0wvW?gg^J-znlJjP5)&G1_nt72KM_3|GV|yXVkx1e`ffL^&j)Ak}MR6X<%UR NkAEPtN-{tG_dgaXX5jz; literal 0 HcmV?d00001 diff --git a/package.json b/package.json index 28e2eb4..475532d 100644 --- a/package.json +++ b/package.json @@ -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", @@ -22,5 +23,8 @@ "bugs": { "url": "https://github.com/CUBETIQ/data-migration-nodejs/issues" }, - "homepage": "https://github.com/CUBETIQ/data-migration-nodejs#readme" + "homepage": "https://github.com/CUBETIQ/data-migration-nodejs#readme", + "dependencies": { + "xlsx": "^0.16.9" + } } diff --git a/src/index.js b/src/index.js index 423cfa4..ac69e9b 100644 --- a/src/index.js +++ b/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); \ No newline at end of file