From: Peter Szinek Date: 2007-11-09T03:04:13+09:00 Subject: Re: problem with zipfile.read -> array (line by line) Hi Christian, > have anybody a hint how i could extract information only for the > first column in a zipped csv. > The hole csv-file is in the array instead line by line as i'm > expected, so i get only the first > character. > > #match_f.csv are 3-column and many millions row file. > Zip::ZipFile.open("f:/base_data/match_df.zip",Zip::ZipFile::CREATE) > { |zipfile| > array=zipfile.read("match_df.csv" ).split("\t") > puts array[0] > } You can also use a csv library (e.g. fasterCSV http://fastercsv.rubyforge.org/, or the standard Ruby one). If you want to process the file line by line, you should split it on "\n", then process each line. Code-snippet: zipfile.read("match_df.csv" ).split.each do |row| puts row.split(",")[0] end In the second split, you should use the delimiter used in the csv file (\t for instance). Cheers, Peter ___ http://www.rubyrailways.com http://scrubyt.org