Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
import Foundation
let content = "abc,cde,5.5,128,256\nefg,ghi,42"
let parsedCSV: [[CustomStringConvertible]] = content
.components(separatedBy: "\n")
.map({
$0.components(separatedBy: ",")
.filter({ Int($0) != nil })
})
print(parsedCSV)
//[["128", "256"], ["42"]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment