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/parsing/methods below:

Methods | Fast-CSV

parse#

Definition: parse(opts?: ParserOptionsArgs): CsvParserStream

Creates a Csv Parsing Stream that can be piped or written to.

This is the main entry point and is used by all the other parsing helpers.

import * as fs from 'fs';

import { parse } from 'fast-csv';

fs.createReadStream('my.csv')

.pipe(parse())

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

.on('data', row => console.log(row))

.on('end', (rowCount: number) => console.log(`Parsed ${rowCount} rows`));

parseStream#

csv.parseStream(readableStream, opts?: ParserOptionsArgs): CsvParserStream

Accepts a readable stream and pipes it to a CsvParserStream.

import * as fs from 'fs';

import { parseStream } from 'fast-csv';

const stream = fs.createReadStream('my.csv');

parseStream(stream)

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

.on('data', row => console.log(row))

.on('end', (rowCount: number) => console.log(`Parsed ${rowCount} rows`));

parseFile#

Definition: parseFile(path: string, opts?: ParserOptionsArgs): CsvParserStream

Parses a file from the specified path and returns the CsvParserStream.

import * as fs from 'fs';

import { parseFile } from 'fast-csv';

parseFile('my.csv')

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

.on('data', row => console.log(row))

.on('end', (rowCount: number) => console.log(`Parsed ${rowCount} rows`));

parseString#

csv.parseString(csv: string, opts?: ParserOptionsArgs): CsvParserStream

This method parses a string and returns the CsvParserStream.

import { EOL } from 'os';

import { parseString } from '@fast-csv/parse';

const CSV_STRING = ['a,b', 'a1,b1', 'a2,b2'].join(EOL);

parseString(CSV_STRING, { headers: true })

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

.on('data', row => console.log(row))

.on('end', (rowCount: number) => console.log(`Parsed ${rowCount} rows`));


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