Append data to a big csv file.
npm install csv-appendLow memory overhead, append-only csv writer.
Abstraction over csv-write-stream.
``sh`
yarn add csv-append
`typescript./data/output.csv
import csvAppend from "csv-append";
const RELATIVE_PATH_TO_CSV = ;
const { append, end } = csvAppend(RELATIVE_PATH_TO_CSV);
append([{ a: 1, b: 2 }, { a: 2, b: 3 }]);
// Or
append({ a: 1, b: 2 });
append({ a: 2, b: 3 });
await end();
console.log(fs.readFileSync(RELATIVE_PATH_TO_CSV, { encoding: "utf8" }));
/*
a,b
1,2
b,3
*/
`
`typescript./data/output.csv
import csvAppend from "csv-append";
const RELATIVE_PATH_TO_CSV = ;
const { append, end } = csvAppend(RELATIVE_PATH_TO_CSV, true);
// append([{ a: 1, b: 2 }, { a: 2, b: 3 }]);
// Or
append({ a: 1, b: 2 });
append({ a: 2, b: 3 });
await end();
console.log(fs.readFileSync(RELATIVE_PATH_TO_CSV, { encoding: "utf8" }));
/*
a,b
1,2
b,3
*/
`
#### Input :
- path: string (required)boolean
- appendToFile: (optional, default false)
#### Output :
`typescript`
{
append: append (👇),
end: end (👇)
}
append adds an object or an array of objects to the end of the csv file.
#### Input :
- args: Array
#### Output :
void
end returns a promise that resolves when the csv has been written to the fs.
#### Input :
None
#### Output :
Promise