class RGovData::CsvDataSet
This is the catalog class that describes a CSV file service DataSet
Public Instance Methods
attribute_value(row,attribute)
click to toggle source
Returns the value of the named attribute
from a recordset row
> overrides RGovData::DataSet.attribute_value
¶ ↑
# File lib/rgovdata/service/dataset/csv_dataset.rb, line 15 def attribute_value(row,attribute) row[attribute.to_s] end
attributes()
click to toggle source
Returns array of attributes that describe the records of the specific entity
> overrides RGovData::Dn.attributes
¶ ↑
# File lib/rgovdata/service/dataset/csv_dataset.rb, line 8 def attributes records unless @attributes # forces a load @attributes end
Protected Instance Methods
load_instance()
click to toggle source
Loads the native dataset (URI or File)
> overrides RGovData::DataSet.load_instance
¶ ↑
# File lib/rgovdata/service/dataset/csv_dataset.rb, line 21 def load_instance if uri =~ /^.+:\/\// URI.parse( uri ) else File.new(uri, "r") end end
load_records()
click to toggle source
Loads the native record set
> overrides RGovData::DataSet.load_records
¶ ↑
# File lib/rgovdata/service/dataset/csv_dataset.rb, line 32 def load_records csv = CSV.new(open(native_instance),{:headers=>:first_row}).read @attributes = csv.headers if limit.present? csv.entries[0,limit] else csv.entries end end