我怎样才能在这种CSV文件中使用数据?或者我如何打印"内部"列的第2行值并将其分配给属性/实体?
我有这样的文件,我从excel文件转换为Numbers,我想获取每列的数据并使用它们.
以数字打开的原始CSV文件:
我得到的控制台输出:
使用这种方法:
func readDataFromCSV(fileName:String, fileType: String)-> String!{
guard let filepath = Bundle.main.path(forResource: fileName, ofType: fileType)
else {
return nil
}
do {
var contents = try String(contentsOfFile: filepath, encoding: .utf8)
contents = cleanRows(file: contents)
return contents
} catch {
print("File Read Error for file \(filepath)")
return nil
}
}
func cleanRows(file:String)->String{
var cleanFile = file
cleanFile = cleanFile.replacingOccurrences(of: "\r", with: "\n")
cleanFile = cleanFile.replacingOccurrences(of: "\n\n", with: "\n")
// cleanFile = cleanFile.replacingOccurrences(of: ";;", with: "")
// cleanFile = …Run Code Online (Sandbox Code Playgroud) 在演示模式下,我只希望未隐藏的幻灯片以连续的页码显示。如何避免计算隐藏的幻灯片?