-
Notifications
You must be signed in to change notification settings - Fork 36
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
csv generator #558
csv generator #558
Conversation
|
||
def wrapInQuotes(input: String): String = { | ||
if (input.contains(SEPARATOR)) | ||
"\"" + input + "\"" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if input already contains a quote?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benwaffle this is not about input containing a quote, this is about input containing a comma. Description could easily contain a comma, and I think this is good future-proofing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I wasn't clear. I agree that this part is needed. But let's say the input already has a quote, e.g. hello, "world"
. I believe your code would output "hello, "world""
. That would cause problems. The way to solve it (by rfc4180) is to replace each double quote ("
) inside the string with two quotes (""
), resulting in "hello, ""world"""
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, now I understand your point. Thank you. I will update to handle quotes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use Apache [commons-csv] to handle CSV output
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, that's a good idea, i'll try to plug it in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sullis @benwaffle - it now uses commons-csv
40403a0
to
538d9c1
Compare
0e29c65
to
b3a28f2
Compare
b3a28f2
to
407d1cc
Compare
407d1cc
to
416dd07
Compare
Spreadsheet-friendly information about your service. I'm starting with resources.csv, which returns information like this: