下面是文件,条目是分隔符
sample.txt的
id\a_po87y Jack leader
id\ruio66 John_Marsha leader
id\rzd766 123_Smart_option fresher
.......
........
etc
我试图将值分成3个数组,如下所示
id = ["id\a_po87y", "id\ruio66", "id\rzd766", ....]
store = ["Jack", "John_Marsha", "123_Smart_option", ....]
group = ["leader", "leader", "fresher", ....]
我的不完整代码如下。
id = Array.new
store = Array.new
group = Array.new
File.open("D:\sample.txt", "r").each_line do |line|
id << line.split("\t")
#not sure how to cpature the remaining entries
end
我对ruby很新,我在Ruby文档中搜索了其他选项,但遗憾的是我无法找到我需要的东西。请帮助
&#34;输出应为&#34;在3个不同的数组中,而不是在一个数组中
id = ["id\a_po87y", "id\ruio66", "id\rzd766", ....]
store = ["Jack", "John_Marsha", "123_Smart_option", ....]
group = ["leader", "leader", "fresher", ....]