2021-07-26-ruby操作CSV文件

1
2
3
4
5
6
# read a file directly
require 'csv'
CSV.read("favorite_foods.csv")

# CSV文件有表头
table = CSV.parse(File.read("cats.csv"), headers: true)