nef
nef7d ago

Possible to use CsvParseStream in Node.js

Hi, is it possible to use nodejs file streams with deno's stdlib?
import fs from "node:fs";
import { CsvParseStream } from "@std/csv";

fs.createReadStream("./data.csv")
.pipe(new CsvParseStream()); // incompatible types
import fs from "node:fs";
import { CsvParseStream } from "@std/csv";

fs.createReadStream("./data.csv")
.pipe(new CsvParseStream()); // incompatible types
5 Replies
nef
nefOP7d ago
as far as I can tell there's nothing in @std/path or @std/fs that opens a file I'm sure loading to a string is possible, but the file is fairly big
marvinh.
marvinh.6d ago
There is no function to open a file in any of the @std packages, because that's already included in Deno itself, see https://docs.deno.com/examples/streaming_files/
nef
nefOP6d ago
yeah sorry I'm trying to use the libraries from node.js with jsr's node compatibility I'm still interested if it's possible but for now I'm using npm's csv-parse
marvinh.
marvinh.6d ago
Right, in that case it's likely that you're running into the issue that Node by default uses NodeStreams (older API) and @std is written for WebStreams. In Node you can convert between the two, see https://nodejs.org/api/webstreams.html#nodejs-streams-interoperability
nef
nefOP6d ago
oooh that looks like it, thank you!

Did you find this page helpful?