Skip to content

Function: fetchCsv()

fetchCsv<T>(url, schema, options?): Promise<StaticDecode<T>[]>

Fetch CSV from the URL and parse according to the given schema

Type Parameters

Type Parameter
T extends TCsvSchema

Parameters

ParameterTypeDescription
urlstringURL to the CSV file
schemaTOutput schema mapping of each row
options?FetchOptionsFetch options FetchOptions

Returns

Promise<StaticDecode<T>[]>

An array of objects corresponded to the table definition

Throws

If fail to fetch or parse the schema

Example

ts
const output = await fetchCsv('https://url-to/data.csv', schema);

Defined in

src/parser/fetch-csv.ts:34

Released under the MIT License.