From a7258f94a868b8574d5216ed86fc5b58a42e5166 Mon Sep 17 00:00:00 2001 From: Vignesh Kumar Date: Fri, 5 Feb 2021 09:17:57 +0530 Subject: [PATCH] Resolved issues 27 & 21 --- SwiftCSVExport/Sources/CSVConstants.swift | 10 ++++++---- SwiftCSVExport/Sources/CSVExport.swift | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/SwiftCSVExport/Sources/CSVConstants.swift b/SwiftCSVExport/Sources/CSVConstants.swift index ee050de..2cf1d7c 100644 --- a/SwiftCSVExport/Sources/CSVConstants.swift +++ b/SwiftCSVExport/Sources/CSVConstants.swift @@ -106,11 +106,13 @@ extension String { if let string = value as? String { // Wrap around double quotes let doubleQuotes = "'" - - let fString = doubleQuotes+"\(string)"+doubleQuotes - return self.length == 0 ? fString : "\(self)\(div) \(string)" + var fString = doubleQuotes+"\(string)"+doubleQuotes + if (self.count == 0) { + fString = string + } + return self.length == 0 ? fString : "\(self)\(div)\(string)" } else { - return self.length == 0 ? "\(value)" : "\(self)\(div) \(value)" + return self.length == 0 ? "\(value)" : "\(self)\(div)\(value)" } } diff --git a/SwiftCSVExport/Sources/CSVExport.swift b/SwiftCSVExport/Sources/CSVExport.swift index 0e391e1..6766cf4 100644 --- a/SwiftCSVExport/Sources/CSVExport.swift +++ b/SwiftCSVExport/Sources/CSVExport.swift @@ -84,11 +84,11 @@ import Foundation let value = valuesArray[i]; if let lessPrecisePI = Float(value) { - rowsDictionary.setObject(lessPrecisePI, forKey: key as NSCopying); + rowsDictionary.setValue(lessPrecisePI, forKey: key); } else if let morePrecisePI = Double(value) { - rowsDictionary.setObject(morePrecisePI, forKey: key as NSCopying); + rowsDictionary.setValue(morePrecisePI, forKey: key); } else { - rowsDictionary.setObject(value, forKey: key as NSCopying); + rowsDictionary.setValue(value, forKey: key); } } return rowsDictionary;