All Projects → vslinko → deno-csv

vslinko / deno-csv

Licence: MIT license
Streaming API for reading and writing CSV for https://deno.land/

Programming Languages

typescript
32286 projects
Makefile
30231 projects
javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to deno-csv

crypto
🔐 Fastest crypto library for Deno written in pure Typescript. AES, Blowfish, CAST5, DES, 3DES, HMAC, HKDF, PBKDF2
Stars: ✭ 40 (+17.65%)
Mutual labels:  deno
snatchblock
A strictly typed utility library.
Stars: ✭ 1,059 (+3014.71%)
Mutual labels:  deno
calcite
A rust framework for creating deno plugins
Stars: ✭ 62 (+82.35%)
Mutual labels:  deno
dataStructure
Implement different Data Structures using TypeScript and JavaScript. Deno Third-party Module.
Stars: ✭ 24 (-29.41%)
Mutual labels:  deno
tsafe
🔩 The missing TypeScript utils
Stars: ✭ 285 (+738.24%)
Mutual labels:  deno
microdiff
A fast, zero dependency object and array comparison library. Significantly faster than most other deep comparison libraries and has full TypeScript support.
Stars: ✭ 3,138 (+9129.41%)
Mutual labels:  deno
cotton
SQL Database Toolkit for Deno
Stars: ✭ 129 (+279.41%)
Mutual labels:  deno
aqua
A minimal and fast 🏃 web framework for Deno
Stars: ✭ 219 (+544.12%)
Mutual labels:  deno
deno-pokemon
a simple api to create and explore pokemons - made with oak deno framework
Stars: ✭ 20 (-41.18%)
Mutual labels:  deno
maze generator
A work-in-progress Javascript maze generator module, compatible with both Deno and Node. 🌽
Stars: ✭ 35 (+2.94%)
Mutual labels:  deno
http4ts
Server as a Function http toolkit for TypeScript & JavaScript
Stars: ✭ 30 (-11.76%)
Mutual labels:  deno
youtube-sr
Simple library for Node, Deno & Bun to make YouTube search easily
Stars: ✭ 68 (+100%)
Mutual labels:  deno
angular deno
Angular Deno - Experimental Angular renderer in server with Deno
Stars: ✭ 78 (+129.41%)
Mutual labels:  deno
denocker
A Docker client library for Deno
Stars: ✭ 23 (-32.35%)
Mutual labels:  deno
jike-sdk
Ⓙ Jike SDK for Node.js / Deno / browser
Stars: ✭ 34 (+0%)
Mutual labels:  deno
node2deno
Deno for Node.js developers
Stars: ✭ 19 (-44.12%)
Mutual labels:  deno
nanoid
A NanoID implementation for Deno
Stars: ✭ 63 (+85.29%)
Mutual labels:  deno
bundle
An online tool to quickly bundle & minify your projects, while viewing the compressed gzip/brotli bundle size, all running locally on your browser.
Stars: ✭ 475 (+1297.06%)
Mutual labels:  deno
lmdb-js
Simple, efficient, ultra-fast, scalable data store wrapper for LMDB
Stars: ✭ 270 (+694.12%)
Mutual labels:  deno
johanbrook.com
Naming the repo "johanbrook.com" was a mistake.
Stars: ✭ 17 (-50%)
Mutual labels:  deno

deno-csv

Streaming API for reading and writing CSV for https://deno.land/.

tag Build Status license deno doc

Usage

Reading

Read CSV file

import { readCSV } from "https://deno.land/x/csv/mod.ts";

const f = await Deno.open("./example.csv");

for await (const row of readCSV(f)) {
  console.log("row:");
  for await (const cell of row) {
    console.log(`  cell: ${cell}`);
  }
}

f.close();

Read CSV file with custom separators

import { readCSV } from "https://deno.land/x/csv/mod.ts";

const f = await Deno.open("./example.csv");

const options = {
  columnSeparator: ";",
  lineSeparator: "\r\n",
  quote: "$",
};

for await (const row of readCSV(f, options)) {
  console.log("row:");
  for await (const cell of row) {
    console.log(`  cell: ${cell}`);
  }
}

f.close();

Read objects from CSV file with header row

import { readCSVObjects } from "https://deno.land/x/csv/mod.ts";

const f = await Deno.open("./example.csv");

for await (const obj of readCSVObjects(f)) {
  console.log(obj);
}

f.close();

Read CSV file manually

import { readCSVObjects } from "https://deno.land/x/csv/mod.ts";

const f = await Deno.open("./example.csv");

let row: string[] = [];
const reader = new CSVReader(f, {
  columnSeparator: "\t",
  lineSeparator: "\r\n",
  onCell(cell: string) {
    row.push(cell);
  },
  onRowEnd() {
    console.log(row);
    row = [];
  },
  onEnd() {
    console.log("end");
    f.close();
  },
  onError(err) {
    console.error(err);
  },
});
reader.read();

Writing

Write CSV file

import { writeCSV } from "https://deno.land/x/csv/mod.ts";

const f = await Deno.open("./example.csv", {
  write: true,
  create: true,
  truncate: true,
});
const rows = [
  ["a", "b", "c"],
  ["1", "2", "3"],
];

await writeCSV(f, rows);

f.close();

Write objects asynchronously to CSV file

import { writeCSVObjects } from "https://deno.land/x/csv/mod.ts";

const f = await Deno.open("./example.csv", {
  write: true,
  create: true,
  truncate: true,
});
const header = ["a", "b", "c"];
const asyncObjectsGenerator = async function* () {
  yield { a: "1", b: "2", c: "3" };
  yield { a: "4", b: "5", c: "6" };
};

await writeCSVObjects(f, asyncObjectsGenerator(), { header });

f.close();

Write CSV file manually

import { CSVWriter } from "https://deno.land/x/csv/mod.ts";

const f = await Deno.open("./example.csv", {
  write: true,
  create: true,
  truncate: true,
});

const writer = new CSVWriter(f, {
  columnSeparator: "\t",
  lineSeparator: "\r\n",
});

await writer.writeCell("a");
await writer.writeCell("b");
await writer.writeCell("c");
await writer.nextLine();
await writer.writeCell("1");
await writer.writeCell("2");
await writer.writeCell("3");

f.close();

Benchmarks

test-node-csv-parse
Read 500001 lines for 8.937 seconds
test-deno-csv-CSVReader
Read 500001 lines for 8.986 seconds
test-deno-csv-readCSVRows
Read 500001 lines for 9.425 seconds
test-deno-csv-readCSVStream
Read 500001 lines for 13.657 seconds
test-deno-csv-readCSV
Read 500001 lines for 15.814 seconds
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].