Skip to content

siokas/deno_load_csv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

deno_load_csv

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/

Installation

import load_csv from "https://raw.githubusercontent.com/siokas/deno_load_csv/master/mod.ts";

Usage example

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'
});

ToDo

  • option to shaffle data
  • extract certain columns

Used

Meta

Apostolos Siokas – @siokas_[email protected]

Contributing

  1. Fork it (https://github.com/yourname/yourproject/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

License

Distributed under the MIT License.

About

Loads csv data from a given file to an array.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published