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
Configure escaping scalar #13
Conversation
Hi @josh, thank you for your kind words and taking the time to send a PR. Exposing the escaping scalar in the API is the right thing to do and your code looks great. I would agree with you about generalizing the case to allow other escaping scalars (like single quotes). In that light, I would like to ask you the following:
Also, if the escaping scalar configuration is exposed in the Regards, |
👍 All sound good. Let me get on that today. Thanks for the feedback!!
I was thinking about that as well and I'm happy to attempt. How do you think we should handle the let input = [
["title"],
["This will be \"ok\" since there's no comma"],
["This field would be , invalid"]
]
try CSVWriter.serialize(rows: input) { $0.escapingStrategy = .none } |
Just throw a new .init(.invalidInput, reason: "...", help: "...", userInfo: ["Invalid character": delimiter]) |
@dehesa pushed some changes. Please have a look. Thanks for all the suggestions so far. |
Hey @josh I have reviewed the PR and it is great, thank you! I merged your changes and add some details that I forgot to mention before:
I have created a new release with your code and some structural changes I was working on to support Linux. Thank you again! 🎉 If you are secluded at home (due to current circumstances) and want to keep helping out in CodableCSV check out the repo projects (specifically the Features project) 😂 Regards, |
Thank you @dehesa! I'll checkout the projects page for more ideas. |
Hi @dehesa, thanks for publishing this library and keeping it super well documented. The code looks great.
I'm currently trying to parse a foreign TSV file that includes unescaped
"
characters in it's fields. I did seeescapingScalar
was exposed as an internal setting but wasn't publicly configurable. For my use case, disabling field escaping worked perfect. And it would be great to expose this ability on the reader configuration.I added a new enum for "escaping strategy". My use case fits into the new
.none
case. And the default case is.doubleQuote
. Though, I was wondering if we should definite the options narrowly and just provide the two, or allow for any character to be used as a escaping pair. Maybe there's a single quoted escaped CSV out there? Would love to hear your thoughts.Thanks!
@josh