rufuspollock / csv.js Goto Github PK
View Code? Open in Web Editor NEWSimple, ultra-light (10kb) JS library for CSV parsing. Works in browser and node with zero dependencies.
Home Page: http://okfnlabs.org/projects/csv.js/
License: MIT License
Simple, ultra-light (10kb) JS library for CSV parsing. Works in browser and node with zero dependencies.
Home Page: http://okfnlabs.org/projects/csv.js/
License: MIT License
We are using the recline library to instantiate a csv backend to generate charts using nvd3, however I am getting an error that I do not understand:
Uncaught TypeError: this._store.query is not a function
The error is coming from the recline model on line 201 (the dataset->query method):
this._store.query(actualQuery, this.toJSON()) ...
The dataset instance in question is using the csv backend, which (when I output it to the console on model init) does not seem to have a query method set on it. Consequently, when this._store is set to backend by the dataset model there is no query method and the above error is thrown.
I'm unclear why I'm seeing this behavior and am wondering if anyone has any insight.
Originally from @amercader here datopian/datahub#304.
The background for this is trying to store a GeoJSON string in a CSV to display it on the map view. Recline won't parse this correctly:
name,geom
Test, "{\"type\":\"Point\",\"coordinates\":[-1.1207,45.4874]}"
The following will work, but it is not always possible to define the text delimiter, eg in CKAN (Note the single quote):
name,geom
Test, '{"type":"Point","coordinates":[-1.1207,45.4874]}'
RFC 7111 support would allow the use of row=
, col=
, and cell=
to be selected via the URL Fragment--or even a combination of them via Multi-Selection
Here are the basic syntax rules.
I've came across this issue trying to parse a csv that uses \r
as line ending. That is a common line ending in Mac OS up to version 9.
As result such files are wrongly parsed.
This happen because the line ending \n
is hardcoded in several places in the code. Example: https://github.com/okfn/csv.js/blob/master/csv.js#L124
Working in a PR.
You are passing the dataset to the parse function, but it assumes you get the dialect hash, so it will not reach down from the dataset to the dialect hash so the dialect options are ignored and the default options are used.
FIX1: Rename parse function argument dialect to dataset and create local variable dialect from the dataset
FIX2: Pass dialect hash to parse function
URL links to csv-dialect needs to be changed from;
http://dataprotocols.org/csv-dialect/
to
https://frictionlessdata.io/specs/csv-dialect/
Should probably turn off auto-casting ...
Try loading this dataset with csv lib in Recline in Firefox (fine in Chrome) and you get an error: https://ckannet-storage.commondatastorage.googleapis.com/2013-01-18T181957/Total-financial-crisis-aid-amounts-used-2008-2011.csv
s.charAt is not a function
The csv.min.js on the master
branch hasn't been updated since commit 5cb7c7 in 2016. There have been a couple of changes to csv.js since then that I was surprised weren't reflected in the minified version.
I was trying to make it closer to RFC, but realized that parsing is used default values. So if I have CSV pipe delimited like
A|B|C
There is no way to pass custom options due to a bug: while m.parse takes options from which it takes delimiter, those options are internal hardcoded
In 'fetch' method there is no way to pass custom options to override delimiter with own
While can pass custom dialect/options to serialize
, the parse
options are hardcoded in my.normalizeDialectOptions
the page at okfnlabs is gone
Since the fetch promise is not being rejected when the ajax call fails then I didn't find a way to handle request errors.
It would be nice to do something like this:
CSV.fetch(dataset)
.done(function(data){....})
.fail(function(error){ console.log(error); });
Working in a PR.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.