0.0.40 • Published 9 months ago
@datastream/csv v0.0.40
@datastream/csv
Commonly used stream patterns for Web Streams API and NodeJS Streams.
- Dependencies
- Support
- Install
- Streams
- Format
- Parse
Dependencies
csv-rex
: CSV parsing and formatting.
Support
NodeJS | Chrome | Edge | Firefox | Safari | |
---|---|---|---|---|---|
Format | 9.4 | 67 | 79 | 102 | 10 |
Parse | 9.4 | 67 | 79 | 102 | 10 |
Install
npm install @datastream/csv
Streams
Format
- Input:
object
orarray
- Output:
string
Options
From the csv-rex
documentation:
Examples
Basic
import { pipeline } from '@datastream/core'
import { csvFormatStream } from '@datastream/csv'
// or
import csvFormatStream from '@datastream/csv/format'
const csvFormatStreamOptions = {}
const streams = [
// Readable stream ...
csvFormatStream(csvFormatStreamOptions),
// Writable stream ...
]
await pipeline(...streams)
NodeJS: format and save to file
import { createWriteStream } from 'node:fs'
import { pipeline, createReadableStream, createTransformStream } from '@datastream/core'
import { csvParseStream } from '@datastream/csv'
const streams = [
createReadableStream([{...},...]),
createTransformStream(() => {...}),
csvFormatStream({ header:[...] }),
createWriteStream('/tmp/output.csv'),
]
await pipeline(...streams)
Parse
- Input:
string
- Output:
object
orarray
Options
See csv-rex
for options
Examples
Basic
import { pipeline } from '@datastream/core'
import { csvParseStream } from '@datastream/csv'
// or
import csvParseStream from '@datastream/csv/parse'
const csvParseStreamOptions = {}
const streams = [
// Readable stream ...
csvParseStream(csvParseStreamOptions),
// Writable stream ...
]
await pipeline(streams)
NodeJS: Read file and parse
import { createReadStream } from 'node:fs'
import { pipeline, createTransformStream, createWritableStream } from '@datastream/core'
import { csvParseStream } from '@datastream/csv'
const streams = [
createReadStream('/tmp/input.csv'),
csvParseStream({...}),
createTransformStream(() => {...}),
createWritableStream()
]
await pipeline(streams)
Browser: Read <input type="file">
and parse in a WebWorker
Examples
NodeJS
0.0.40
9 months ago
0.0.39
9 months ago
0.0.38
10 months ago
0.0.37
10 months ago
0.0.36
1 year ago
0.0.30
2 years ago
0.0.31
2 years ago
0.0.32
2 years ago
0.0.33
2 years ago
0.0.34
2 years ago
0.0.35
2 years ago
0.0.21
2 years ago
0.0.22
2 years ago
0.0.23
2 years ago
0.0.24
2 years ago
0.0.25
2 years ago
0.0.26
2 years ago
0.0.27
2 years ago
0.0.28
2 years ago
0.0.29
2 years ago
0.0.20
2 years ago
0.0.19
2 years ago
0.0.10
3 years ago
0.0.11
3 years ago
0.0.12
3 years ago
0.0.14
3 years ago
0.0.15
3 years ago
0.0.9
3 years ago
0.0.16
3 years ago
0.0.17
2 years ago
0.0.18
2 years ago
0.0.8
3 years ago
0.0.7
3 years ago
0.0.5
3 years ago
0.0.4
3 years ago
0.0.6
3 years ago
0.0.3
3 years ago
0.0.2
3 years ago
0.0.1
3 years ago
0.0.0
3 years ago