Skip to content

csvhuman - New Alternative (CSV) HXL Library / Gem in Ruby #5

@geraldb

Description

@geraldb

Hello, first thanks for trying to build a ruby version for supporting HXL. I'm the author of the (new) csvreader library / gem and I added a new library / gem, that is, csvhuman, see https://github.com/csvreader/csvhuman, that lets you read tabular data in the CSV Humanitarian eXchange Language (HXL) format in ruby. Example:

pp CsvHuman.parse( <<TXT )      ## or use HXL.parse
  What,,,Who,Where,For whom,
  Record,Sector/Cluster,Subsector,Organisation,Country,Males,Females,Subregion
  ,#sector+en,#subsector,#org,#country,#sex+#targeted,#sex+#targeted,#adm1
  001,WASH,Subsector 1,Org 1,Country 1,100,100,Region 1
  002,Health,Subsector 2,Org 2,Country 2,,,Region 2
  003,Education,Subsector 3,Org 3,Country 2,250,300,Region 3
  004,WASH,Subsector 4,Org 1,Country 3,80,95,Region 4
TXT

More ways to use the reader:

csv = CsvHuman.new( recs )
csv.each do |rec|
  pp rec
end

pp csv.read


CsvHuman.parse( recs ).each do |rec|
  pp rec
end


pp CsvHuman.read( "./test.csv" )

CsvHuman.foreach( "./test.csv" ) do |rec|
  pp rec
end

#...

or use the HXL alias:

hxl = HXL.new( recs )
hxl.each do |rec|
  pp rec
end

pp hxl.read


HXL.parse( recs ).each do |rec|
  pp rec
end


pp HXL.read( "./test.csv" )

HXL.foreach( "./test.csv" ) do |rec|
  pp rec
end

#...

Cheers. Prost.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions