A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://c2fo.github.io/fast-csv/docs/formatting/methods below:

Methods | Fast-CSV

Methods format#

csv.format(options): CsvFormatterStream

This is the main entry point for formatting CSVs. It is used by all other helper methods.

import { format } from '@fast-csv/format';

const stream = format();

stream.pipe(process.stdout);

stream.write(['a', 'b']);

stream.write(['a1', 'b1']);

stream.write(['a2', 'b2']);

stream.end();

write#

write(rows[, options]): CsvFormatterStream

Create a formatter, writes the rows and returns the CsvFormatterStream.

import { write } from '@fast-csv/format';

const rows = [

['a', 'b'],

['a1', 'b1'],

['a2', 'b2'],

];

write(rows).pipe(process.stdout);

writeToStream#

writeToStream(stream, rows[, options])

Write an array of values to a WritableStream, and returns the original stream

import { writeToStream } from '@fast-csv/format';

const rows = [

['a', 'b'],

['a1', 'b1'],

['a2', 'b2'],

];

writeToStream(process.stdout, rows);

writeToPath#

writeToPath(path, rows[, options])

Write an array of values to the specified path

import { writeToPath } from '@fast-csv/format';

const rows = [

['a', 'b'],

['a1', 'b1'],

['a2', 'b2'],

];

writeToPath(path.resolve(__dirname, 'tmp.csv'), rows)

.on('error', err => console.error(err))

.on('finish', () => console.log('Done writing.'));

writeToString#

writeToString(arr[, options]): Promise<string>

Formats the rows and returns a Promise that will resolve with the CSV content as a string.

import { writeToString } from '@fast-csv/format';

const rows = [

['a', 'b'],

['a1', 'b1'],

['a2', 'b2'],

];

writeToString(rows).then(data => console.log(data));

writeToBuffer#

writeToBuffer(arr[, options]): Promise<Buffer>

Formats the rows and returns a Promise that will resolve with the CSV content as a Buffer.

import { writeToBuffer } from '@fast-csv/format';

const rows = [

['a', 'b'],

['a1', 'b1'],

['a2', 'b2'],

];

writeToBuffer(rows).then(data => console.log(data.toString()));


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4