https://github.com/alwint3r/any-to-csv
Convert any data to CSV format
https://github.com/alwint3r/any-to-csv
deno typescript
Last synced: 3 months ago
JSON representation
Convert any data to CSV format
- Host: GitHub
- URL: https://github.com/alwint3r/any-to-csv
- Owner: alwint3r
- Created: 2022-07-31T16:37:48.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-07-31T17:03:54.000Z (almost 4 years ago)
- Last Synced: 2025-10-31T05:42:19.972Z (8 months ago)
- Topics: deno, typescript
- Language: TypeScript
- Homepage:
- Size: 1000 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Any Data to CSV
Convert any kind of data to a CSV format with a straightforward API.
## Supported Platforms
* Deno
## Usage
```ts
import { toCsv, HeaderSpec, CsvDataValue } from 'https://raw.githubusercontent.com/alwint3r/any-to-csv/main/mod.ts';
const data = [
{ name: 'Anakin', job: 'Padawan' },
{ name: 'Obi-Wan', job: 'Jedi Master' },
];
const headers: HeaderSpec[] = [
{ name: 'name', as: 'Name', transform: (value: CsvDataValue) => (value as string).toUpperCase() },
{ name: 'job', as: 'Job' },
];
const csv = toCsv(data, headers);
console.log(csv);
// will print
// Name,Job
// ANAKIN,Padawan
// OBI-WAN,Jedi Master
```