I'm trying to create a CSV file with some text in it using playgrounds. This is the code:
// The text to save
let csvText = "Hello,World,Goodbye!"
// The path
var document = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first
var fileURL = document?.appendingPathComponent("result.csv")
// Writing text to path
do {
try csvText.write(to: fileURL!, atomically: true, encoding: .utf8)
} catch {
print("something went wrong..")
}
The code does work - it makes a .CSV file with the text inside. The problem is that the text isn't placed in columns. See image below:
The text should be placed under column A B and C.
I thought you define columns by using commas, that's why the words in my csvText
constant are separated by commas. Why doesn't this work?