From: piir@... (Todd Gardner) Date: 2004-06-18T07:28:23+09:00 Subject: Re: How to read a .csv file into a 2D array? "NAKAMURA, Hiroshi" wrote in message news:<40CFB0A5.5070900@keynauts.com>... > Hi, Todd, > > Todd Gardner wrote: > > Do you have any idea what I may be doing wrong in the code below? > > Seems to be a command line escaping problem. Try this on the same console. > > C:\home\ruby\bin>ruby -rcsv -e "p CSV.open(ARGV.shift, 'r', ?\t).collect > { |row| row.to_a }" \temp\Todd.tsv > > It dumps followings for me. > > [["CREDIT", "20040505120000[0:GMT]", "PAYMENT - THANK YOU", "1"], > ["CREDIT", "20 > 040309120000[0:GMT]", "PAYMENT - THANK YOU", "146.8"], ["CREDIT", > "2004032912000 > 0[0:GMT]", "PAYMENT - THANK YOU", "1500"], ["CREDIT", > "20040409120000[0:GMT]", " > PROFESSIONAL CAREER DEV", "1082.05"], ["DEBIT", "20040601120000[0:GMT]", > "TARGET > 00003236", "-21.64"], ["DEBIT", "20040502120000[0:GMT]", "TARGET > 00003236", "-113.32"], ["DEBIT", "20040417120000[0:GMT]", "TARGET > 0000323 > 6", "-47.02"], ["CREDIT", "20040327120000[0:GMT]", "TARGET > 00003236", "12 > 9.89"], ["DEBIT", "20040326120000[0:GMT]", "USPS 0568370007", "-8.85"], > ["DEBIT" > , "20040508120000[0:GMT]", "USPS 5654840286", "-7.85"], ["DEBIT", > "2004051012000 > 0[0:GMT]", "USPS 5654840286", "-12.55"]] > > > Domo Arigato Agimashita I'm trying to say many thanks. I am guessing > > you won't be able to tell because of my almost nonexistent Japanese, > > "Domo Arigato" is completely a valid Japanese. Thank you for trying to > write in Japanese. > I hope my English accessible. ^^^^^^^^^^ acceptable At least, that's what I "think" you are saying. And yes, your English is quite acceptable. > Regards, > // NaHi Hello NaHi, I greatly appreciate any of your input. I don't believe I have changed the problem however, I continue to get an error. I am guessing I don't have the file "Todd.tsv" in the proper location. INPUT E:\Documents and Settings\tnt\ruby\ex\array>ruby -rcsv -e "p CSV.open(ARGV.shift , 'r', ?\t).collect { |row| row.to_a }" \temp\Todd.tsv OUTPUT c:/ruby/lib/ruby/1.8/csv.rb:228:in `initialize': No such file or directory - \te mp\Todd.tsv (Errno::ENOENT) from c:/ruby/lib/ruby/1.8/csv.rb:228:in `open' from c:/ruby/lib/ruby/1.8/csv.rb:228:in `open_reader' from c:/ruby/lib/ruby/1.8/csv.rb:208:in `open' from -e:1 =================================================================== E:\Documents and Settings\tnt\ruby\ex\array>dir Volume in drive E is ROY2D2P2 Volume Serial Number is 60B9-9B87 Directory of E:\Documents and Settings\tnt\ruby\ex\array 06/17/2004 02:48p . 06/17/2004 02:48p .. 06/13/2004 04:37p 269 010.rbw 06/13/2004 04:48p 344 020.rbw 06/15/2004 12:43p 92 030.rbw 06/15/2004 06:13p 81 040.rbw 06/13/2004 03:42a 353 test.csv 06/13/2004 03:42a 353 test1.csv 06/13/2004 04:37p 353 test1.out 06/17/2004 02:25p 353 Todd.tsv 8 File(s) 2,198 bytes 2 Dir(s) 111,811,252,224 bytes free Do I have the file Todd.tsv in the proper location? Domo Arigato, Todd