--0016e6de1524ca1056046f6d5f85 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Just change the "," as record delimiter.... for example try a "\t" (TAB). You can easily change this through Excel if you export your file as CSV 2009/7/23 Robert Schaaf <ruby-bucket / comcast.net> > But what if your addressee is Samuel Barber at Capricorn, Mt. Kisko, NY. > Or in the Brill Building at 1619 Broadway, Suite 511, New York, NY? Or a > law firm such as Miller, Mertens & Comfort, P.L.L.C. ? > > Excel will export these as > > Samuel Barber,"Capricorn, Mt. Kisco",NY > Tin Pan Alley,"1619 Broadway, Suite 511", New York, NY > "Miller, Mertens & Comfort, P.L.L.C.","1020 North Center Parkway, Suite > B",Kennenwick,WA > > Other systems might escape internal commas. Worse, grabbing rows from a > database and injecting commas between them, will lead to unparsable results. > > There is no easy solution to this problem; you really have to parse on > well-formed input. > > Bob Schaaf > > > > On Jul 23, 2009, at 8:17 AM, Mirko Viviani wrote: > > something similar... >> >> fi = File.open("yourfile", "r") >> >> #get key values >> header = fi.gets.chomp.split(",") >> allValues = [] >> >> while (!fi.eof) >> values = fi.gets.chomp.split(",") >> allValues << header.zip(values) >> end >> >> fi.close >> >> puts allValues.inspect >> >> >> >> >> >> 2009/7/23 Hunt Hunt <aksn18july / gmail.com> >> >> Hi Friends, >>> >>> I have a file which information.txt which is like >>> >>> name,address,city,contact >>> abc,Newyork,HYU,345 >>> xyz,Pittsurg,UYY,234 >>> >>> >>> only theree line. >>> >>> Now I have to split name, address,city & contact with their associated >>> values. >>> >>> how am i supposed to do this? >>> >>> Thanks for the information in advance. >>> >>> Regards >>> HUNT/RUDIN >>> -- >>> Posted via http://www.ruby-forum.com/. >>> >>> >>> >> >> -- >> -- Mirko Viviani -- >> GPG-PGP Public Key: 0xE4E8FAB1 >> Fingerprint: 14D3 A373 E926 7737 DF32 502B A4C4 1CE2 E4E8 FAB1 >> *********************************************** >> "Ůachines take me by surprise with great frequency.A. Turing >> > > -- -- Mirko Viviani -- GPG-PGP Public Key: 0xE4E8FAB1 Fingerprint: 14D3 A373 E926 7737 DF32 502B A4C4 1CE2 E4E8 FAB1 *********************************************** "Ůachines take me by surprise with great frequency.A. Turing --0016e6de1524ca1056046f6d5f85--