tabreader library / gem v1.0 - read in tabular datafiles in text in the tabular (TAB) format

Gerald Bauer <[email protected]>
Newsgroups gmane.comp.lang.ruby.general
Message-ID <CAAxEZd-OPbfBNjK9EefjJ9fv=s+zHcJ94RkEzsfFt+xgN2XX3g@mail.gmail.com>
Hello,

   I've published the tabreader library / gem version 1.0 [1]
that lets you read in tabular datafiles in text in the tabular (TAB) format.


Yes, it's as simple as:

    line = "1\t2\t3"
    values = line.split( "\t" )
    pp values
    # => ["1","2","3"]

or the "magic" packaged up in `TabReader`:


    line = "1\t2\t3"
    values = Tab.parse_line( line )   ## or TAB.parse_line or
TabReader.parse_line
    pp values
    # => ["1","2","3"]


or use the convenience helpers:

    txt <<=TXT
    1\t2\t3
    4\t5\t6
    TXT

    records = Tab.parse( txt )   ## or TAB.parse or TabReader.parse
    pp records
    # => [["1","2","3"],
    #     ["4","5","6"]]

or

    records = Tab.read( "values.tab" )  ## or TAB.read or TabReader.read
    pp records
    # => [["1","2","3"],
    #     ["4","5","6"]]

or

    Tab.foreach( "values.tab" ) do |rec|  ## or TAB.foreach or TabReader.foreach
      pp rec
    end
    # => ["1","2","3"]
    # => ["4","5","6"]

and so on.


Happy data wrangling with ruby. Cheers. Prost.

PS: The FAQ in the README includes:

- Q: Why NOT use Csv.read( sep: "\t" )?
- Q: What's the tabulator (TAB) format?
- Q: Why tab?
- Q: Why NOT tab?


[1] https://github.com/csv11/tabreader

Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.