mimimi / ruby-tsv

Simple TSV parser
MIT License
37 stars 4 forks source link

Allow using opened IO object as `TSV::parse` argument #3

Closed GreyCat closed 9 years ago

GreyCat commented 9 years ago

This is an enhancement of high-level API that allows to use not only strings, fully pre-loaded into memory, but really any suitable object that has #each_line. First and foremost, it makes it possible to use pre-opened IO objects, for example, something like that:

file = params['myfile'][:tempfile]
file.set_encoding('utf-8')
TSV::parse(file).each { |row|
  ...
}

where that [:tempfile] stuff is a pre-opened TempFile object made by user web file upload.

Slotos commented 9 years ago

+1

Thank you for pull request