Skip to content

Instantly share code, notes, and snippets.

@alsedi
Last active December 4, 2018 20:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alsedi/47e06de83e20695660fe3e1f58ac4cf8 to your computer and use it in GitHub Desktop.
Save alsedi/47e06de83e20695660fe3e1f58ac4cf8 to your computer and use it in GitHub Desktop.
import Foundation
let content = "abc,cde,128,256\nefg,ghi,42" //string with CSV file content
// parsing
let parsedCSV: [[String]] = content.components(separatedBy: "\n").map{ $0.components(separatedBy: ",") }
print(parsedCSV)
// ["abc","cde","128","256"],["efg","ghi","42"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment