小编Max*_*ohl的帖子

swift 3.1如何从CSV获取数组或字典

我怎样才能在这种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)

csv parsing swift3

23
推荐指数
5
解决办法
2万
查看次数

如何不为PPT中的隐藏幻灯片计算页码?

在演示模式下,我只希望未隐藏的幻灯片以连续的页码显示。如何避免计算隐藏的幻灯片?

powerpoint powerpoint-vba powerpoint-2013

6
推荐指数
1
解决办法
1万
查看次数