Last active
February 8, 2017 22:14
-
-
Save alsedi/ef873fdd7ee6294702082b6cb68c9d26 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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