SVR 0.1

Simple reader for csv, tsv, or in general any character separated string. The reader instance acts like a doubly linked list: prev, next, current, end.

In addition, it's a little smart about how it reads. SVR will not parse the complete string buffer until you want to read the next line.



Details

Author
Olmo Maldonado
Current version
0.1
GitHub
ibolmo/SVR.js
Downloads
1618
Category
Utilities
Tags
Report
GitHub Issues

Releases


Dependencies

  • _self_/_current_:
    • Core/Class
    • Core/Class.Extras

How to use

Log each line

var line, reader = new SVR(my_tsv); // tab separate variable, the default 
while (line = reader.next()) console.log(line);

First 5 lines

var line, reader = new SVR(my_csv, {delimeter: ','});
while (line = reader.next() && reader.index < 5) console.log(line);

Reverse Reading

var reader = new SVR(my_tsv);
for (var line = reader.end(); reader.prev();) console.log(line); 

Build

Build via Packager, requires MooTools Core to be registered to Packager already

./packager register /path/to/SVR
./packager build SVR/* > SVR.js

Todo

  • End could be more optimal. I shouldn't have to parse all of the buffer to iterate backwards.
  • Do something with the headers (assumed to be line 0).
  • Web 2.0. Could hook into JSONP, XHR, etc., to grab the inputs. Right now it's on the developer to provide the string buffer as the first argument.
  • The reading is one-dimensional (per line). What if it was two-dimensional with a per column?

Discuss

A note on comments here: These comments are moderated. No comments will show up until they are approved. Comments that are not productive (i.e. inflammatory, rude, etc) will not be approved.

Found a bug in this plugin? Please report it this repository's Github Issues.

blog comments powered by Disqus