输入文件如下所示:
狗,白,男 猫,紫色,女性 大鼠,灰色,男性
我想逐行处理这些数据并做一些事情。
File.open("animals.csv")
while file has next line
currentline = array with each cell being an entry in the array
if currentline[0] == dog
put "dogs are cool"
end
put "your animal is a " + currentline[0]
end
你明白了,对吧?我想用 ifs 和诸如此类的东西来操作数据线,并在最后打印出来。
谢谢