From e26c05420bc0c458b90929abe89b40da5806eb85 Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Sun, 14 Sep 2025 20:22:11 -0700 Subject: [PATCH] Add example of processing `.csv.gz` files --- examples/README.md | 2 ++ examples/data/ex1_9-in.csv.gz | Bin 0 -> 92 bytes examples/data/ex1_9-out.csv.gz | Bin 0 -> 87 bytes examples/ex1_9.js | 33 +++++++++++++++++++++++++++++++++ test/examples.test.js | 17 +++++++++++++++-- 5 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 examples/data/ex1_9-in.csv.gz create mode 100644 examples/data/ex1_9-out.csv.gz create mode 100644 examples/ex1_9.js diff --git a/examples/README.md b/examples/README.md index 607878a..4238659 100644 --- a/examples/README.md +++ b/examples/README.md @@ -30,6 +30,8 @@ These examples demonstrate the most common, expected usage. [Example 1.8: Read from `stdin` and write to `stdout`](./ex1_8.js) ([input](./data/ex1_8-in.csv), [output](./data/ex1_8-out.csv)) +[Example 1.9: Read and write a `.csv.gz` file](./ex1_9.js) ([input](./data/ex1_9-in.csv.gz), [output](./data/ex1_9-out.csv.gz)) + ### Section 2: Error strategies These examples demonstrate using the `onError` option to handle transformations that may throw errors. diff --git a/examples/data/ex1_9-in.csv.gz b/examples/data/ex1_9-in.csv.gz new file mode 100644 index 0000000000000000000000000000000000000000..70028c2f7fc821d05b1f6f41e6b3a11e472b24e2 GIT binary patch literal 92 zcmV-i0HgmOiwFqJe4%Ip|7CbFUpOvlZZ2bUb^s;Cxeaq yhZzSudpzfR-5b`sC{%O|{KSlIghxy-p?3t4(`vK?liA2h_4)v*+uB@30002gK_`s> literal 0 HcmV?d00001 diff --git a/examples/data/ex1_9-out.csv.gz b/examples/data/ex1_9-out.csv.gz new file mode 100644 index 0000000000000000000000000000000000000000..53ca6704b07a8040a08b4091f063bca9de036e98 GIT binary patch literal 87 zcmb2|=3oGW|FWkH`5Fv3+#b$tnQd?&o~z`_>XNlqmG!~Pr`J?|j(lG#Z}fkjkAQ(= p=z>#E { ok(actual.equals(expected)); }); } + else if (name === 'ex1_9') { + test(name, { concurrency: true }, async () => { + const output = new URL(`./data/${name}-out.csv.gz`, tempExamples); + const expected = await readFile(output); + await import(code); + const actual = await readFile(output); + ok(actual.equals(expected)); + }); + } else { test(name, { concurrency: true }, async () => { const expected = await readFile(output); -- 2.47.3