This folder contains end-to-end examples of using this library.
-All examples assume your current working directory is **this folder**. All examples can be run directly without additional setup using `node`. E.g.:
+All examples can be run directly without additional setup using `node`. E.g.:
```
-cd examples
-node ./ex1.js
+node ./examples/ex1.js
```
return [Number(row[0]) * 2, Number(row[1]) * 2];
}
-createCSVReadableStream('./data/ex1-in.csv')
+createCSVReadableStream(new URL('./data/ex1-in.csv', import.meta.url))
.pipeThrough(createCSVTransformStream(timesTwo))
- .pipeTo(createCSVWritableStream('./data/ex1-out.csv'));
\ No newline at end of file
+ .pipeTo(createCSVWritableStream(new URL('./data/ex1-out.csv', import.meta.url)));
\ No newline at end of file
return [...row, Number(row[0]) + Number(row[1])];
}
-createCSVReadableStream('./data/ex2-in.csv')
+createCSVReadableStream(new URL('./data/ex2-in.csv', import.meta.url))
.pipeThrough(createCSVTransformStream(sum, { includeHeaders: true }))
- .pipeTo(createCSVWritableStream('./data/ex2-out.csv'));
\ No newline at end of file
+ .pipeTo(createCSVWritableStream(new URL('./data/ex2-out.csv', import.meta.url)));
\ No newline at end of file
return [name, paddedId];
}
-createCSVReadableStream('./data/ex3-in.csv')
+createCSVReadableStream(new URL('./data/ex3-in.csv', import.meta.url))
.pipeThrough(createCSVTransformStream(parse, { includeHeaders: true, rawOutput: true }))
.pipeThrough(createCSVTransformStream(calculate, { includeHeaders: true, rawInput: true }))
- .pipeTo(createCSVWritableStream('./data/ex3-out.csv'));
\ No newline at end of file
+ .pipeTo(createCSVWritableStream(new URL('./data/ex3-out.csv', import.meta.url)));
\ No newline at end of file
}
];
-createCSVReadableStream('./data/ex4-in.csv')
+createCSVReadableStream(new URL('./data/ex4-in.csv', import.meta.url))
.pipeThrough(createCSVNormalizationStream(headers))
.pipeThrough(createCSVDenormalizationStream())
- .pipeTo(createCSVWritableStream('./data/ex4-out.csv'));
\ No newline at end of file
+ .pipeTo(createCSVWritableStream(new URL('./data/ex4-out.csv', import.meta.url)));
\ No newline at end of file
return [report, id, date, ...row];
}
-createCSVReadableStream('./data/ex5-in.csv')
+createCSVReadableStream(new URL('./data/ex5-in.csv', import.meta.url))
.pipeThrough(createCSVTransformStream(parse, { includeHeaders: true }))
- .pipeTo(createCSVWritableStream('./data/ex5-out.csv'));
\ No newline at end of file
+ .pipeTo(createCSVWritableStream(new URL('./data/ex5-out.csv', import.meta.url)));
\ No newline at end of file