Skip to content
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

Option to specify delimiter in convenience method #55

Closed
sebromero opened this issue Dec 16, 2013 · 4 comments
Closed

Option to specify delimiter in convenience method #55

sebromero opened this issue Dec 16, 2013 · 4 comments

Comments

@sebromero
Copy link

It would be fantastic if we could have a method like the following

[NSArray arrayWithContentsOfCSVFile:fileURL.path delimiter:@";"]

Now I had to implement a custom class as the parser delegate because the _CHCSVAggregator is a private class. I did it like this:

SCSVAggregator* semicolonSeparatedAggregator = [[SCSVAggregator alloc] init];
NSInputStream *stream = [NSInputStream inputStreamWithFileAtPath:fileURL.path];
NSStringEncoding encoding = 0;
CHCSVParser* semicolonSeparatedParser = [[CHCSVParser alloc] initWithInputStream:stream usedEncoding:&encoding delimiter:';'];
semicolonSeparatedParser.delegate = semicolonSeparatedAggregator;
[semicolonSeparatedParser parse];
@ed-parry
Copy link

Has there been any progress with this issue at all? I'm also having trouble figuring out how to use an alternative delimiter pushing out to an NSArray.

@davedelong
Copy link
Owner

@ed-parry: This functionality exists in the parser; there's just not an easy "one-liner" for it. To use a custom delimiter, you'll have to set up an delegate for the CHCSVParser and have it aggregate the strings. For example, this is how the existing convenience methods are implemented.

But no, I have not been working on this at all. I'm extremely busy.

@davedelong
Copy link
Owner

This is in now. Enjoy.

@ed-parry
Copy link

Fantastic! Thank you, @davedelong and also @yconst!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants