Public
Script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { fetch } from "https://esm.town/v/std/fetch";
import { getDuckDB } from "https://esm.town/v/tmcw/getDuckDB";
export const duckDbCsv = (async () => {
const db = await getDuckDB();
const r = await fetch(
"https://raw.githubusercontent.com/fivethirtyeight/data/master/san-andreas/earthquake_data.csv",
);
await db.registerFileBuffer(
"file.csv",
new Uint8Array(await r.arrayBuffer()),
);
const c = await db.connect();
const res = await c.query(`select * from "file.csv" LIMIT 5`);
c.close();
db.terminate();
return res.toArray().map((r) => r.toJSON());
})();
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
October 23, 2023