NeoCSV at Work :)

Hi,

I know a lot of people are interested in (public) datasets (to use as examples). The website https://numeracy.co contains a (small) number of interesting ones. Here is how to access them using NeoCSV.

(NeoCSVReader on:
 'https://numeracy.co/standard-library/us-population/states.csv' asUrl retrieveContents readStream) upToEnd.

or

ZnClient new
 url: 'https://numeracy.co/standard-library/us-population/states.csv';
 contentReader: [ :entity | (NeoCSVReader on: entity readStream) upToEnd ];
 get.

Of course, they don't use UTF-8 and don't advertise it, so on some datasets you need to do something extra.

(NeoCSVReader on:
  (ZnDefaultCharacterEncoder 
     value: ZnCharacterEncoder latin1
     during: [ 'https://numeracy.co/standard-library/us-population/cities.csv' asUrl retrieveContents ])
     readStream) upToEnd.

(Warning: this last example is quite large, 500K records).

Sven

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: