Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

std/csv/mod.ts>CsvStringifyStream

Deno standard library
Go to Latest
The Standard Library has been moved to JSR. See the blog post for details.
class CsvStringifyStream
extends TransformStream<TOptions["columns"] extends Array<string> ? Record<string, unknown> : Array<unknown>, string>
import { CsvStringifyStream } from "https://deno.land/std@0.194.0/csv/mod.ts";

Convert each chunk to a CSV record.

Examples

Example 1

import { CsvStringifyStream } from "https://deno.land/std@0.194.0/csv/csv_stringify_stream.ts";
import { readableStreamFromIterable } from "https://deno.land/std@0.194.0/streams/readable_stream_from_iterable.ts";

const file = await Deno.open("data.csv", { create: true, write: true });
const readable = readableStreamFromIterable([
  { id: 1, name: "one" },
  { id: 2, name: "two" },
  { id: 3, name: "three" },
]);

await readable
  .pipeThrough(new CsvStringifyStream({ columns: ["id", "name"] }))
  .pipeThrough(new TextEncoderStream())
  .pipeTo(file.writable);

Constructors

new
CsvStringifyStream(options?: TOptions)