CSV ファイルからデータをインポートする方法が見つかりません。データを配列にロードしたい。
これをグーグルで試してみましたが、私の場合は何もうまくいかないようです
これは私の UIDocumentPickerViewController です。
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
let urlst = "\(urls)"
if urlst.fileExtension() == "csv]" || urlst.fileExtension() == "csv" {
// Start Import Action From CSV File
} else {
let alert = UIAlertController(title: "An Error Occured!", message: "The file you were trying to inport is not supported. Only csv is support.", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Ok", style: .default , handler: nil))
alert.addAction(UIAlertAction(title: "Try Again", style: .default , handler: { (UIAlertAction) in
self.toImport()
}))
self.present(alert, animated: true, completion: nil)
}
}
私の予想される結果は、ユーザーが UIDocumentPickerViewController を使用して選択した csv ファイルを取得し、それを 1 つ以上の配列にインポートすることです。しかし、私はこれを機能させる方法を見つけることができません。