Skip to content

Function: fetchCsv()

fetchCsv<T>(url, schema, fetchRequestInit?): 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
fetchRequestInit?FetchRequestInitOptions for fetch() request FetchRequestInit

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:16

Released under the MIT License.