Skip to content
Draft
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
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 Beomjin Kim

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,18 @@ Open `http://localhost:8080/experiments/csv-preflight/` when serving from the re
### Free command-line check

Node.js 20 or newer can run the same generic structural preflight on one local file without a
browser or dependency install:
browser. The repository copy works without an install:

```sh
node cli.mjs input.csv --output normalized.csv --report issues.csv
```

Version 0.6.0 prepares the same command for npm publication:

```sh
npx csv-preflight input.csv --output normalized.csv --report issues.csv
```

The free CLI returns exit 0 for a clean file, 1 for reported issues or rejected input, and 2 for an
invocation/runtime error. It accepts UTF-8 input up to 10 MiB and refuses to overwrite the input or
an existing output. It does not include the Pro archive's batch, Shopify-profile, ZIP, or JSON
Expand Down
1 change: 1 addition & 0 deletions a75acc2ed5874b344f9f70acb44713d4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a75acc2ed5874b344f9f70acb44713d4
5 changes: 3 additions & 2 deletions cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,11 @@ export function runCli(argv, io = {}) {
issues = [{ type: "encoding", row: null, detail: `${detected.encoding} is not supported; export as UTF-8` }];
} else {
const text = new TextDecoder("utf-8", { fatal: true }).decode(bytes.slice(detected.offset));
const result = analyze(text);
const delimiter = guessDelimiter(text);
const result = analyze(text, delimiter);
issues = result.issues;
if (!issues.some(issue => issue.type === "parse" || issue.type === "empty")) {
normalized = new TextEncoder().encode(`\uFEFF${serializeCsv(result.cleanRows)}`);
normalized = new TextEncoder().encode(`\uFEFF${serializeCsv(result.cleanRows, delimiter)}`);
}
}
const targets = normalized ? [config.output, config.report] : [config.report];
Expand Down
13 changes: 13 additions & 0 deletions cli.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ test("free CLI writes a clean normalized file and report", () => {
assert.match(new TextDecoder().decode(writes[1].data), /type,row,detail/);
});

test("free CLI preserves the detected delimiter in normalized output", () => {
const writes = [];
const exit = runCli(["input.csv", "--output", "clean.csv", "--report", "report.csv"], {
readFile: () => bytes("name;price\nMug;12"),
outputExists: () => false,
writeFile: (file, data) => writes.push({ file, data }),
stdout: () => {},
stderr: () => {},
});
assert.equal(exit, 0);
assert.match(new TextDecoder().decode(writes[0].data), /name;price\r\nMug;12/);
});

test("free CLI reports warnings and withholds rejected output", () => {
const warningWrites = [];
const common = { outputExists: () => false, stdout: () => {}, stderr: () => {} };
Expand Down
40 changes: 39 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1 +1,39 @@
{"type":"module","scripts":{"test":"node --test","benchmark":"node benchmark.mjs","benchmark:record":"node benchmark.mjs --write"},"engines":{"node":"22.x"},"private":true}
{
"name": "csv-preflight",
"version": "0.6.0",
"description": "Check one CSV for structural problems before import",
"type": "module",
"bin": {
"csv-preflight": "cli.mjs"
},
"files": [
"cli.mjs",
"LICENSE"
],
"scripts": {
"test": "node --test",
"benchmark": "node benchmark.mjs",
"benchmark:record": "node benchmark.mjs --write",
"prepack": "npm test"
},
"engines": {
"node": ">=20"
},
"keywords": [
"csv",
"validator",
"cli",
"data-quality",
"preflight"
],
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/softpeanut/csv-preflight.git"
},
"homepage": "https://softpeanut.github.io/csv-preflight/",
"bugs": "https://github.com/softpeanut/csv-preflight/issues",
"publishConfig": {
"access": "public"
}
}
Loading