I am trying to read the content of a .csv
file using the framework CreateML to read csv data.
Fhe following code generates an error even though the file exists:
let csvURL = URL(fileURLWithPath: "/Volumes/MAC HDD/Data/Data.csv")
let fm = FileManager()
if (fm.fileExists(atPath: csvURL.path)) {
let dataTable = try! MLDataTable(contentsOf: csvURL)
// accessing first column
let col_1 = Array.init(dataTable["col1"])
}
I get the following error message:
Thread 1: Fatal error: 'try!' expression unexpectedly raised an error: CreateML.MLCreateError.generic(reason: "No files corresponding to the specified path (file:///Volumes/MAC%20HDD/Data/Data.csv)")
I have checked nearly everything but can't get any results. What am I doing wrong?
I found out by my self what the problem is.
I have implemented this code in a Xcode project to read csv data, but the CreateML framework is just working for Xcode Playground and not within a Xcode Project! It was mentioned at the end of the WWDC 2018 session video 703.
The code example above is working fine with Xcode Playground.
It would have saved me a lot of time if there had been a warning when importing the framework.