Quantcast
Channel: How to display and import data from a feed url? - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Answer by the Tin Man for How to display and import data from a feed url?

$
0
0

The data format looks like a variation on CSV, if ';;' is used as a column separator. Based on that:

require 'csv'CSV.parse(data, :col_sep => ';;') do |csv|  # do something with each recordend

data will be the content you receive.

Inside the loop, csv will be an array containing each record's fields. The first time through the loop will be the headers and subsequent times through csv will be the data records.

Sometimes you'll see ';;;;', which means there's an empty field; For instance, field;;;;field which would convert to ['field',nil,'field'] in csv. You'll need to figure out what you want to do with nil records. I'd suggest you'll probably want to map those to empty strings ('').


Viewing all articles
Browse latest Browse all 2