From: Raimon Fs Date: 2008-01-05T18:56:32+09:00 Subject: parsing a csv using ; => ruby doesn't split the row Hello, I'm importing CSV files without problems, now, I have some of them that use the semi-colon instead of the comma as a field separator, I'm trying to adapt my Ruby code for that, but Ruby puts all the columns in the first element, without using the new value as a separator: here's the code: CSV.open(arxiu.file_path , "r", :col_sep => ?;) do |row| @data_new=Cat.new @data_new.reporter = row[0] @data_new.partner = row[1] @data_new.product = row[2] @data_new.period = row[3] @data_new.imp = row[4] @data_new.exp = row[5] @data_new.pes_imp = row[6] @data_new.pes_exp = row[7] @data_new.save end # CSV open do and here is the file: Catalunya;UE;TARIC;ANY;IMP;EXP;PES IMP;PES EXP Catalunya;UE;01021010;2006;6205,1;195,7;0,0;0,0 Catalunya;UE;01021030;2006;66,9;147,7;0,0;0,0 Catalunya;UE;01021090;2006;614,8;3317,2;0,0;0,0 Catalunya;UE;01029005;2006;79166,1;4603,0;0,0;0,0 Catalunya;UE;01029029;2006;19572,2;259,0;5820,0;0,0 ....... and this is what I get: @data_new.reporter=Catalunya;UE;TARIC;ANY;IMP;EXP;PES IMP;PES EXP @data_new.partner = "" @data_new.product = "" @data_new.period = "" @data_new.imp = "" @data_new.exp = "" @data_new.pes_imp = "" @data_new.pes_exp = "" and this is what I want: @data_new.reporter=Catalunya @data_new.partner = UE @data_new.product = TARIC @data_new.period = ANY @data_new.imp = IMP @data_new.exp = EXP @data_new.pes_imp = PES IMP @data_new.pes_exp = PES EXP ... thanks ! raimon -- Posted via http://www.ruby-forum.com/.