🔍
Validate and Infer Type
Define what you expect with a schema and never run into a surprise.
Type-safe CSV and Google Sheets Parser
For TypeScript and JavaScript
npm i sheethuaha
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()),
}),
});
import { parseCsv, fetchCsv, Spreadsheet } from 'sheethuahua';
// const output: {
// id: number;
// name: string;
// contact: {
// email: string;
// phone?: string | undefined;
// };
// }[]
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);
import { formatToCsv } from 'sheethuahua';
const csvString = formatToCsv(output, schema);