import { stringify } from "https://deno.land/std@0.203.0/csv/mod.ts";
Write data using CSV encoding.
Examples
Example 1
Example 1
import {
Column,
stringify,
} from "https://deno.land/std@0.203.0/csv/stringify.ts";
type Character = {
age: number;
name: {
first: string;
last: string;
};
};
const data: Character[] = [
{
age: 70,
name: {
first: "Rick",
last: "Sanchez",
},
},
{
age: 14,
name: {
first: "Morty",
last: "Smith",
},
},
];
let columns: Column[] = [
["name", "first"],
"age",
];
console.log(stringify(data, { columns }));
// first,age
// Rick,70
// Morty,14
Parameters
data: DataItem[]
The source data to stringify. It's an array of items which are plain objects or arrays.
DataItem: Record<string, unknown> | unknown[]
const data = [
{
name: "Deno",
repo: { org: "denoland", name: "deno" },
runsOn: ["Rust", "TypeScript"],
},
];
optional
unnamed 1: StringifyOptions = [UNSUPPORTED]Output formatting options