看板 Ruby 關於我們 聯絡資訊
不好意思,有點急 實在是太虛了,所以向各位求救 我有一筆資料長這樣(共100列) 2,1,4,2,1,1,1,1 3,2,2,2,2,2,1,1 2,1,1,1,2,2,2,1 ........ 想要讀成 [[2,1,4,2,1,1,1,1],[3,2,2,2,2,2,1,1],[2,1,1,1,2,2,2,1],[...]] 我只能寫到這樣 data = File.read("./100.csv"); ary=data.gsub!(/\r/, "") ary.each{|u| p u.chomp! } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 163.17.173.193 ※ 編輯: itucson 來自: 163.17.173.193 (05/08 09:16)
ilake:while t = file.gets do; a << t.chomp.split(',');end 05/08 09:44