forked from wwWallet/wallet-ecosystem
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from gunet/ehic-pickup-code
Redefined EHIC and PDA1
- Loading branch information
Showing
31 changed files
with
784 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,6 @@ docker-compose.yml | |
*.production* | ||
*.tar | ||
.npmrc | ||
dataset.json | ||
dataset.json | ||
*.xlsx | ||
tasks.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export function parsePidData(filePath: string): any; | ||
|
||
export function parseEhicData(filePath: string): any; | ||
|
||
export function parsePda1Data(filePath: string): any; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
const XLSX = require('xlsx'); | ||
const fs = require('fs'); | ||
|
||
|
||
|
||
function parsePidData(filePath) { | ||
const readOpts = { // <--- need these settings in readFile options | ||
cellText: false, | ||
cellDates: true, | ||
type: 'buffer' | ||
}; | ||
const fileBuffer = fs.readFileSync(filePath); | ||
|
||
// Parse the workbook | ||
const workbook = XLSX.read(fileBuffer, readOpts); | ||
const sheetName = "PID" | ||
// Get the first worksheet | ||
const worksheet = workbook.Sheets[sheetName]; | ||
|
||
// Convert worksheet to JSON format | ||
const data = XLSX.utils.sheet_to_json(worksheet, { | ||
defval: undefined, | ||
dateNF: 'd"/"m"/"yyyy' | ||
// skipHidden: true, | ||
// header: 0 | ||
}); | ||
|
||
const headers = Object.values(data[0]).map((h) => h.trim()); | ||
const ncols = Object.keys(headers); | ||
|
||
const result = data.slice(1).map(row => { | ||
row = Object.values(row) | ||
const obj = {}; | ||
row.map((cell, index) => { | ||
obj[headers[index]] = cell; // Assign key-value pairs | ||
}); | ||
|
||
return obj; | ||
}); | ||
|
||
return result; | ||
} | ||
|
||
function parseEhicData(filePath) { | ||
const readOpts = { // <--- need these settings in readFile options | ||
cellText: false, | ||
cellDates: true, | ||
type: 'buffer' | ||
}; | ||
const fileBuffer = fs.readFileSync(filePath); | ||
|
||
// Parse the workbook | ||
const workbook = XLSX.read(fileBuffer, readOpts); | ||
const sheetName = "EHIC" | ||
// Get the first worksheet | ||
const worksheet = workbook.Sheets[sheetName]; | ||
|
||
// Convert worksheet to JSON format | ||
const data = XLSX.utils.sheet_to_json(worksheet, { | ||
defval: undefined, | ||
dateNF: 'd"/"m"/"yyyy' | ||
// skipHidden: true, | ||
// header: 0 | ||
}); | ||
return data; | ||
} | ||
|
||
|
||
function parsePda1Data(filePath) { | ||
const readOpts = { // <--- need these settings in readFile options | ||
cellText: false, | ||
cellDates: true, | ||
type: 'buffer' | ||
}; | ||
const fileBuffer = fs.readFileSync(filePath); | ||
|
||
// Parse the workbook | ||
const workbook = XLSX.read(fileBuffer, readOpts); | ||
const sheetName = "PDA1" | ||
// Get the first worksheet | ||
const worksheet = workbook.Sheets[sheetName]; | ||
|
||
// Convert worksheet to JSON format | ||
const data = XLSX.utils.sheet_to_json(worksheet, { | ||
defval: undefined, | ||
dateNF: 'd"/"m"/"yyyy' | ||
// skipHidden: true, | ||
// header: 0 | ||
}); | ||
|
||
let headers = Object.values(data[0]).map((h) => h.trim()); | ||
|
||
const ncols = Object.keys(headers); | ||
|
||
|
||
const result = data.slice(1).map(row => { | ||
row = Object.values(row) | ||
|
||
const obj = {}; | ||
row.forEach((cell, index) => { | ||
obj[headers[index]] = cell; // Assign key-value pairs | ||
}); | ||
return obj; | ||
}); | ||
|
||
return result; | ||
} | ||
|
||
module.exports = { | ||
parsePidData, | ||
parseEhicData, | ||
parsePda1Data | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "dataset-reader", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"dependencies": { | ||
"xlsx": "^0.18.5" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
# yarn lockfile v1 | ||
|
||
|
||
adler-32@~1.3.0: | ||
version "1.3.1" | ||
resolved "https://registry.yarnpkg.com/adler-32/-/adler-32-1.3.1.tgz#1dbf0b36dda0012189a32b3679061932df1821e2" | ||
integrity sha512-ynZ4w/nUUv5rrsR8UUGoe1VC9hZj6V5hU9Qw1HlMDJGEJw5S7TfTErWTjMys6M7vr0YWcPqs3qAr4ss0nDfP+A== | ||
|
||
cfb@~1.2.1: | ||
version "1.2.2" | ||
resolved "https://registry.yarnpkg.com/cfb/-/cfb-1.2.2.tgz#94e687628c700e5155436dac05f74e08df23bc44" | ||
integrity sha512-KfdUZsSOw19/ObEWasvBP/Ac4reZvAGauZhs6S/gqNhXhI7cKwvlH7ulj+dOEYnca4bm4SGo8C1bTAQvnTjgQA== | ||
dependencies: | ||
adler-32 "~1.3.0" | ||
crc-32 "~1.2.0" | ||
|
||
codepage@~1.15.0: | ||
version "1.15.0" | ||
resolved "https://registry.yarnpkg.com/codepage/-/codepage-1.15.0.tgz#2e00519024b39424ec66eeb3ec07227e692618ab" | ||
integrity sha512-3g6NUTPd/YtuuGrhMnOMRjFc+LJw/bnMp3+0r/Wcz3IXUuCosKRJvMphm5+Q+bvTVGcJJuRvVLuYba+WojaFaA== | ||
|
||
crc-32@~1.2.0, crc-32@~1.2.1: | ||
version "1.2.2" | ||
resolved "https://registry.yarnpkg.com/crc-32/-/crc-32-1.2.2.tgz#3cad35a934b8bf71f25ca524b6da51fb7eace2ff" | ||
integrity sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ== | ||
|
||
frac@~1.1.2: | ||
version "1.1.2" | ||
resolved "https://registry.yarnpkg.com/frac/-/frac-1.1.2.tgz#3d74f7f6478c88a1b5020306d747dc6313c74d0b" | ||
integrity sha512-w/XBfkibaTl3YDqASwfDUqkna4Z2p9cFSr1aHDt0WoMTECnRfBOv2WArlZILlqgWlmdIlALXGpM2AOhEk5W3IA== | ||
|
||
ssf@~0.11.2: | ||
version "0.11.2" | ||
resolved "https://registry.yarnpkg.com/ssf/-/ssf-0.11.2.tgz#0b99698b237548d088fc43cdf2b70c1a7512c06c" | ||
integrity sha512-+idbmIXoYET47hH+d7dfm2epdOMUDjqcB4648sTZ+t2JwoyBFL/insLfB/racrDmsKB3diwsDA696pZMieAC5g== | ||
dependencies: | ||
frac "~1.1.2" | ||
|
||
wmf@~1.0.1: | ||
version "1.0.2" | ||
resolved "https://registry.yarnpkg.com/wmf/-/wmf-1.0.2.tgz#7d19d621071a08c2bdc6b7e688a9c435298cc2da" | ||
integrity sha512-/p9K7bEh0Dj6WbXg4JG0xvLQmIadrner1bi45VMJTfnbVHsc7yIajZyoSoK60/dtVBs12Fm6WkUI5/3WAVsNMw== | ||
|
||
word@~0.3.0: | ||
version "0.3.0" | ||
resolved "https://registry.yarnpkg.com/word/-/word-0.3.0.tgz#8542157e4f8e849f4a363a288992d47612db9961" | ||
integrity sha512-OELeY0Q61OXpdUfTp+oweA/vtLVg5VDOXh+3he3PNzLGG/y0oylSOC1xRVj0+l4vQ3tj/bB1HVHv1ocXkQceFA== | ||
|
||
xlsx@^0.18.5: | ||
version "0.18.5" | ||
resolved "https://registry.yarnpkg.com/xlsx/-/xlsx-0.18.5.tgz#16711b9113c848076b8a177022799ad356eba7d0" | ||
integrity sha512-dmg3LCjBPHZnQp5/F/+nnTa+miPJxUXB6vtk42YjBBKayDNagxGEeIdWApkYPOf3Z3pm3k62Knjzp7lMeTEtFQ== | ||
dependencies: | ||
adler-32 "~1.3.0" | ||
cfb "~1.2.1" | ||
codepage "~1.15.0" | ||
crc-32 "~1.2.1" | ||
ssf "~0.11.2" | ||
wmf "~1.0.1" | ||
word "~0.3.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.