Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,25 @@ This line is not parsable : {"key4": "value2", "key5":}
Launch this command, just update the sourcePath env var :

```
cross-env sourcePath=pathToYourFileWithoutExtension node scripts/transform/detectErrorInJsonByLine.js
cross-env sourcePath=pathToYourFileWithoutExtension node scripts/validation/detectErrorInJsonByLine.js
```

Without sourcePath env var, the script choose the file in dataset folder

### detectErrorInJsonsInsideFolder

Iterate over each json file in specified folder to log every not parsable files, like

#### How to launch

Launch this command, just update the sourcePath env var :

```
cross-env sourcePath=pathToYourFolder node scripts/validation/detectErrorInJsonsInsideFolder.js
```

Without sourcePath env var, the script choose the folder `folderOfJsons` in dataset folder

## Ping

Launch a ping with your nodeJS network configuration. It's helpfull if you want to check the connectivity between your
Expand Down
10 changes: 5 additions & 5 deletions package-lock.json
100755 → 100644

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"scripts": {
"start-ping": "cross-env ipToPing= node ./scripts/ping.js",
"start-detectErrorInJsonByLine": "cross-env sourcePath= node scripts/validation/detectErrorInJsonByLine.js",
"start-detectErrorInJsonsInsideFolder": "cross-env sourcePath= node scripts/validation/detectErrorInJsonsInsideFolder.js",
"start-convertObjectByLineToObjectsArray": "cross-env sourcePath= node scripts/transform/convertObjectByLineToObjectsArray.js",
"start-convertCsvToJson": "cross-env sourcePath= node scripts/transform/convertCsvToJson.js",
"start-transformEveryObjectInObjectByLine": "cross-env sourcePath= node scripts/transform/transformEveryObjectsInObjectByLine.js",
Expand Down
25 changes: 25 additions & 0 deletions scripts/validation/detectErrorInJsonsInsideFolder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const fs = require('fs');
const path = require('path');

const folderPath = process.env.sourcePath ? process.env.sourcePath : `${__dirname}/../../dataset/validation/folderOfJsons`;

const jsonsToValidate = fs.readdirSync(path.resolve(folderPath));

(async () => {
console.log(`detectErrorInJsonsInsideFolder in process for this folder ${folderPath}`)
for (const jsonFile of jsonsToValidate) {
if(jsonFile.endsWith('.json')){
let rawJson = fs.readFileSync(`${folderPath}/${jsonFile}`);
try {
if (rawJson) {
JSON.parse(rawJson.toString());
}
} catch (e) {
console.error("ERROR : This file is not a valid json :", jsonFile, e)
}
}

}
console.log(`detectErrorInJsonsInsideFolder is ended`)
})();