-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How are you handling quotes and commas? #6
Comments
Hi Harris, Can you please test it with my example? It is working fine. Example file: ViewController.swift |
Hi Vignesh – I can’t get your example to compile, as CSV() is not found anywhere. But here is a slightly modified version, that shows you that the entrie’s with commas cause them not to return from readCSV. Am I missing something?
// Generate CSV file
let user1:NSMutableDictionary = NSMutableDictionary()
user1.setObject("vignesh", forKey: "name" as NSCopying);
user1.setObject("vigneshuvi@gmail.com", forKey: "email" as NSCopying);
user1.setObject("Hi Vignesh, \nhow are you? \t Shall we meet tomorrow? \r Thanks ", forKey: "address" as NSCopying);
let user2:NSMutableDictionary = NSMutableDictionary()
user2.setObject("vinoth", forKey: "name" as NSCopying);
user2.setObject("vinoth@gmail.com", forKey: "email" as NSCopying);
user2.setObject("Hi Vinoth, \nHow are you? \t Shall we meet tomorrow? \r Thanks ", forKey: "address" as NSCopying);
let data:NSMutableArray = NSMutableArray()
data.add(user1);
data.add(user2);
let filePath:String = SwiftCSVExport.exportCSV("userlist",fields: ["name", "email", "address"],values: data);
print(filePath)
let fileDetails = readCSV(filePath);
print(fileDetails)
name,email,address
"vignesh","vigneshuvi@gmail.com","Hi Vignesh, \nhow are you? \t Shall we meet tomorrow? \r Thanks "
"vinoth","vinoth@gmail.com","Hi Vinoth, \nHow are you? \t Shall we meet tomorrow? \r Thanks "
/Users/harris/Library/Developer/CoreSimulator/Devices/14EAFB36-DAA5-4916-8CB4-F4C01478756F/data/Containers/Data/Application/DD59324C-AEA2-4F57-B43E-411374D7AF03/Documents/Exports/userlist.csv
{
}
From: Vignesh <notifications@github.com>
Reply-To: vigneshuvi/SwiftCSVExport <reply@reply.github.com>
Date: Sunday, December 17, 2017 at 10:13 PM
To: vigneshuvi/SwiftCSVExport <SwiftCSVExport@noreply.github.com>
Cc: harrisrap <harris@harrisrappaport.com>, Author <author@noreply.github.com>
Subject: Re: [vigneshuvi/SwiftCSVExport] How are you handling quotes and commas? (#6)
Hi Harris,
Can you please test it with my example? It is working fine.
Example file: ViewController.swift
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
And here is the exact same code, with the only change being me deleting the comma after “Vignesh”.
// Generate CSV file
let user1:NSMutableDictionary = NSMutableDictionary()
user1.setObject("vignesh", forKey: "name" as NSCopying);
user1.setObject("vigneshuvi@gmail.com", forKey: "email" as NSCopying);
user1.setObject("Hi Vignesh \nhow are you? \t Shall we meet tomorrow? \r Thanks ", forKey: "address" as NSCopying);
let user2:NSMutableDictionary = NSMutableDictionary()
user2.setObject("vinoth", forKey: "name" as NSCopying);
user2.setObject("vinoth@gmail.com", forKey: "email" as NSCopying);
user2.setObject("Hi Vinoth \nHow are you? \t Shall we meet tomorrow? \r Thanks ", forKey: "address" as NSCopying);
let data:NSMutableArray = NSMutableArray()
data.add(user1);
data.add(user2);
let filePath:String = SwiftCSVExport.exportCSV("userlist",fields: ["name", "email", "address"],values: data);
print(filePath)
let fileDetails = readCSV(filePath);
print(fileDetails)
name,email,address
"vignesh","vigneshuvi@gmail.com","Hi Vignesh \nhow are you? \t Shall we meet tomorrow? \r Thanks "
"vinoth","vinoth@gmail.com","Hi Vinoth \nHow are you? \t Shall we meet tomorrow? \r Thanks "
/Users/harris/Library/Developer/CoreSimulator/Devices/14EAFB36-DAA5-4916-8CB4-F4C01478756F/data/Containers/Data/Application/B654E600-5E5B-4DD0-8826-160CC4977FF1/Documents/Exports/userlist.csv
{
fields = (
name,
email,
address
);
name = "userlist.csv";
rows = (
{
address = "\"Hi Vignesh \\nhow are you? \\t Shall we meet tomorrow? \\r Thanks \"";
email = "\"vigneshuvi@gmail.com\"";
name = "\"vignesh\"";
},
{
address = "\"Hi Vinoth \\nHow are you? \\t Shall we meet tomorrow? \\r Thanks \"";
email = "\"vinoth@gmail.com\"";
name = "\"vinoth\"";
}
);
}
From: Harris Rappaport <harris@harrisrappaport.com>
Date: Sunday, December 17, 2017 at 10:37 PM
To: vigneshuvi/SwiftCSVExport <reply@reply.github.com>
Subject: Re: [vigneshuvi/SwiftCSVExport] How are you handling quotes and commas? (#6)
Hi Vignesh – I can’t get your example to compile, as CSV() is not found anywhere. But here is a slightly modified version, that shows you that the entrie’s with commas cause them not to return from readCSV. Am I missing something?
// Generate CSV file
let user1:NSMutableDictionary = NSMutableDictionary()
user1.setObject("vignesh", forKey: "name" as NSCopying);
user1.setObject("vigneshuvi@gmail.com", forKey: "email" as NSCopying);
user1.setObject("Hi Vignesh, \nhow are you? \t Shall we meet tomorrow? \r Thanks ", forKey: "address" as NSCopying);
let user2:NSMutableDictionary = NSMutableDictionary()
user2.setObject("vinoth", forKey: "name" as NSCopying);
user2.setObject("vinoth@gmail.com", forKey: "email" as NSCopying);
user2.setObject("Hi Vinoth, \nHow are you? \t Shall we meet tomorrow? \r Thanks ", forKey: "address" as NSCopying);
let data:NSMutableArray = NSMutableArray()
data.add(user1);
data.add(user2);
let filePath:String = SwiftCSVExport.exportCSV("userlist",fields: ["name", "email", "address"],values: data);
print(filePath)
let fileDetails = readCSV(filePath);
print(fileDetails)
name,email,address
"vignesh","vigneshuvi@gmail.com","Hi Vignesh, \nhow are you? \t Shall we meet tomorrow? \r Thanks "
"vinoth","vinoth@gmail.com","Hi Vinoth, \nHow are you? \t Shall we meet tomorrow? \r Thanks "
/Users/harris/Library/Developer/CoreSimulator/Devices/14EAFB36-DAA5-4916-8CB4-F4C01478756F/data/Containers/Data/Application/DD59324C-AEA2-4F57-B43E-411374D7AF03/Documents/Exports/userlist.csv
{
}
From: Vignesh <notifications@github.com>
Reply-To: vigneshuvi/SwiftCSVExport <reply@reply.github.com>
Date: Sunday, December 17, 2017 at 10:13 PM
To: vigneshuvi/SwiftCSVExport <SwiftCSVExport@noreply.github.com>
Cc: harrisrap <harris@harrisrappaport.com>, Author <author@noreply.github.com>
Subject: Re: [vigneshuvi/SwiftCSVExport] How are you handling quotes and commas? (#6)
Hi Harris,
Can you please test it with my example? It is working fine.
Example file: ViewController.swift
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@harrisrap , Can you please update your pod?
|
Why? I installed it fresh earlier today. Did you update it today?
… On Dec 17, 2017, at 11:19 PM, Vignesh ***@***.***> wrote:
@harrisrap , Can you please update your pod file?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@harrisrap , Can you please let me know what is your local version of "SwiftCSVExport"? You can find the local version in pod.lock file and open lock file in text editor! Exmaple: PODS:
|
- SwiftCSVExport (1.0.5)
I installed it with this line:
pod 'SwiftCSVExport'
From: Vignesh <notifications@github.com>
Reply-To: vigneshuvi/SwiftCSVExport <reply@reply.github.com>
Date: Sunday, December 17, 2017 at 11:26 PM
To: vigneshuvi/SwiftCSVExport <SwiftCSVExport@noreply.github.com>
Cc: harrisrap <harris@harrisrappaport.com>, Mention <mention@noreply.github.com>
Subject: Re: [vigneshuvi/SwiftCSVExport] How are you handling quotes and commas? (#6)
@harrisrap , Can you please let me what is your local version of "SwiftCSVExport"?
You can find the local version in pod.lock file and open lock file in texteditor?
Exmaple:
PODS:
SwiftCSVExport (1.0.6)
SwiftLoggly (1.0.5)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Can you please use pod update to install latest version? |
Can you please provide sample code to reproduce this issue? |
That worked! I’m not sure why 1.06 didn’t get installed by default when I used pod install?
One more question, if I may:
Does the csv have to be in a file? I have csv in a string that I’d like to read into a dictionary. Is there a function call for that?
Like readCSV(string: csvString)
Thanks!
Harris.
From: Vignesh <notifications@github.com>
Reply-To: vigneshuvi/SwiftCSVExport <reply@reply.github.com>
Date: Monday, December 18, 2017 at 12:44 AM
To: vigneshuvi/SwiftCSVExport <SwiftCSVExport@noreply.github.com>
Cc: harrisrap <harris@harrisrappaport.com>, Mention <mention@noreply.github.com>
Subject: Re: [vigneshuvi/SwiftCSVExport] How are you handling quotes and commas? (#6)
Can you please use pod update to install latest version?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Hi @harrisrap Will check pod install issue. for dictionary format read:
|
for me trying to read a csv i download from excel wont work when there are commas that are inside the string |
exportCSV:
Quotes in values are written as they are, which causes problems when opening up in Excel.
Ideally, any " found in values should be turned into "".
readCSV:
Any row with a value that contains a comma seems to be ignored.
(But values with commas do get written fine by exportCSV.)
The text was updated successfully, but these errors were encountered: