rufuspollock-okfn / dataexplorer

View, visualize, clean and process data in the browser.
http://explorer.okfnlabs.org
148 stars 47 forks source link

Tutorial - basic clean up #127

Closed rufuspollock closed 10 years ago

rufuspollock commented 11 years ago

Here's some great example data:

http://static.london.gov.uk/gla/expenditure/docs/2012-13-P12-250.csv

djw commented 11 years ago

Using the current scripting interface this can be achieved using the following script:

dataset.fields = _.reject(dataset.fields, function (field) {return field.id === "_noname_";});
_.find(dataset.fields, function (field) {return field.id === "Clearing Date";}).type="date";

_.each(dataset.records, function (record) {
  delete record._noname_;
  if (typeof record.Amount === "string") {
    record.Amount = parseFloat(record.Amount.replace(/,/g, ""));
  }
  if (typeof record["Clearing Date"] === "string") {
    record["Clearing Date"] = new Date(record["Clearing Date"]);
  }
});

saveDataset(dataset);

One caveat being that the date parsing wont work cross-browser. We maybe need to make Moment available to the worker, or provide a utility function on the memory backend.

djw commented 11 years ago

Probably has a dependence on #129

rufuspollock commented 11 years ago

@djw what's the status here? This is the last item to close :-)

djw commented 11 years ago

@rgrp This is blocking on the syntax changes in #126. Once they're in, you just need to create a project with the above CSV and script, using the okfn github account, and change the link in index.html.

rufuspollock commented 11 years ago

@djw i've responded on #126.

djw commented 11 years ago

The above code just needs to be put inside the new loadDataset call.

nmashton commented 11 years ago

@djw @rgrp I wrote a Labs blog post that turned your data and code into a simple introduction to Explorer's capabilities.

rufuspollock commented 10 years ago

FIXED.