sheethuahua
v3.0.0
Published
Type-safe Google Sheets and CSV parser for TypeScript and JavaScript
Downloads
135
Readme
Table of Contents generated with DocToc
Sheethuahua
Type-safe CSV and Google Sheets Parser for TypeScript and JavaScript
Using TypeBox, d3-dsv and Web Fetch API under the hood, Sheethuahua should be supported by every modern browsers and back-end runtime.
1. Adopt our little doggo
npm i sheethuaha
2. Describe what you want
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 get 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);
Released under the MIT License - Copyright © 2024-present Punch Up