It is a simple function that loads csv data from a given file to an array. It uses the Deno.readFile method to read and parse the file with TextDecoder. https://deno.land/std/fs/
import load_csv from "https://raw.githubusercontent.com/siokas/deno_load_csv/master/mod.ts";
Just call the load_csv() method passing the filename (in absolute path). The method returns an object with the headers and the data.
let { headers, data } = await load_csv("./MY_FILE.csv");
You may also pass an object with options as headers and decode. (By default it is set as headers:true, decode: 'utf-8')
let { data } = await load_csv("./MY_FILE.csv", {
headers:false,
decode:'windows-1251'
});
- option to shaffle data
- extract certain columns
Apostolos Siokas – @siokas_ – [email protected]
- Fork it (https://github.com/yourname/yourproject/fork)
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request
Distributed under the MIT License.