3.1.0 • Published 8 months ago

sheethuahua v3.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

Sheethuahua

Type-safe CSV and Google Sheets parser for TypeScript and JavaScript

Sheethuahua

Using TypeBox, d3-dsv, Web Fetch API (and Tempo for date transformer) under the hood, Sheethuahua should be supported by every modern browsers and back-end runtime.

NPM Version

📖 View full documentation

1. Adopt our little doggo

npm i sheethuaha

2. Map CSV and JS data structure

import { Column, Object, asNumber, asString } from 'sheethuahua';

const schema = Object({
	id: Column('ID', asNumber()),
	name: Column('Name', asString()),
	contact: Object({
		email: Column('Email Address', asString()),
		phone: Column('Phone Number', asString().optional()),
	}),
});

3. And confidently parse it

import { parseCsv, fetchCsv, Spreadsheet } from 'sheethuahua';

// const output: {
//     id: number;
//     name: string;
//     contact: {
//         email?: string | undefined;
//         phone: string;
//     };
// }[]
const output = parseCsv('some,csv,string', schema);

// or from URL
const output = await fetchCsv('https://url-to-csv', schema);

// or from Google Sheets
const sheets = Spreadsheet('google-sheets-id');
const output = await sheets.get('Sheet1', schema);

4. In case you need to format the data back

import { formatToCsv } from 'sheethuahua';

const csvString = formatToCsv(output, schema);

Released under the MIT License - Copyright © 2024-present Punch Up

3.1.0

8 months ago

3.0.0

9 months ago

2.1.0

10 months ago

2.0.0

1 year ago

1.0.0

1 year ago