CSwiftV
一个符合(并测试了)rfc4180的 csv 解析器,即(csv)规范最接近的东西。
目前它是全部在内存中的,所以不适合非常大的文件。
TL;DR
let inputString = "Year,Make,Model,Description,Price\r\n1997,Ford,E350,descrition,3000.00\r\n1999,Chevy,Venture,another description,4900.00\r\n"
let csv = CSwiftV(with: inputString)
let rows = csv.rows // [
// ["1997","Ford","E350","descrition","3000.00"],
// ["1999","Chevy","Venture","another description","4900.00"]
// ]
let headers = csv.headers // ["Year","Make","Model","Description","Price"]
let keyedRows = csv.keyedRows // [
// ["Year":"1997","Make":"Ford","Model":"E350","Description":"descrition","Price":"3000.00"],
// ["Year":"1999","Make":"Chevy","Model":"Venture","Description":"another, description","Price":"4900.00"]
// ]