From: Felix Feelx Date: 2010-02-03T07:56:28+09:00 Subject: Re: Parsing text with while loop. Felix Feelx wrote: > Aldric Giacomoni wrote: >> Felix Feelx wrote: >>> I am parsing a csv file and I am unable to end my loop as I want it. >>> >>> When I run my ruby file, I get this : >>> >>> feelx@tbiweb:~/public_html$ ruby csv_to_sql.rb >>> /usr/lib/ruby/1.8/date/format.rb:1055:in `dup': can't dup NilClass >>> (TypeError) >>> from /usr/lib/ruby/1.8/date/format.rb:1055:in `_parse' >>> from /usr/lib/ruby/1.8/date.rb:999:in `parse' >>> from csv_to_sql.rb:43 >>> >>> Link to my code : http://pastie.org/806415 >>> >>> Thanks in advance. >>> >>> Felix >> >> Why wouldn't you trust JEGII's CSV library (or 'FasterCSV' if you are on >> 1.8') ? It does all the hard work of parsing CSV for you. > > Because the content of the csv is not constant. It's not built as a > database file... Why doing : begin end until (blop[24] == "Total:") if blop[24] contains a string would give an error saying "can't dup NilClass"? -- Posted via http://www.ruby-forum.com/.