You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

30 lines
768 B

//
// Description.swift
// SwiftCSV
//
// Created by Will Richardson on 11/04/16.
// Copyright © 2016 Naoto Kaneko. All rights reserved.
//
import Foundation
extension CSV: CustomStringConvertible {
public var description: String {
let head = header.joined(separator: ",") + "\n"
let cont = namedRows.map { row in
return header.map { key -> String in
let value = row[key]!
// Add quotes if value contains a comma
if value.contains(",") {
return "\"\(value)\""
}
return value
}.joined(separator: ",")
}.joined(separator: "\n")
return head + cont
}
}