/fread

Javascript CSV and Image file reader using the FileReader API

Primary LanguageJavaScript

fread - js file reader

Build Status

fread is a tiny javascript library that allows you to display uploaded files via the FileReader API (currently only CSV and Image files). It has no external dependencies.

Read more documentation and see examples here

fread API

options

  • in : file input selector
  • out : output table selector
  • before : called before table is rendered
  • after : called after table is rendered, receives an argument representing each row

default usage

<input type="file" id="files" name="files[]" multiple />
<table id="list" class="table table-bordered table-striped">
  <thead></thead>
  <tbody></tbody>
</table>
// use default writer
var fread = new fread({
  in: '#files',
  out: '#list'
  before: function(evt){
    // perform some action before render
  },
  after: function(headers, rows){
    // perform some action with rows array
  }
});

custom writer

// use a custom writer
var fread = new fread({
  in: '#file-input',
  writer: function(headers, rows){
    // write data to the page
  }
});

See examples/index.html or the live example

Installation

bower install fread

or Download and include lib/fread.js in your page