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

csv generator #558

Merged
merged 1 commit into from
Aug 15, 2019
Merged

csv generator #558

merged 1 commit into from
Aug 15, 2019

Conversation

mchimirev
Copy link
Collaborator

@mchimirev mchimirev commented Aug 13, 2019

Spreadsheet-friendly information about your service. I'm starting with resources.csv, which returns information like this:

method,path
POST,/v1/account-service/v1/account-service/accounts/sign-in,Sign in (log in)
POST,/v1/account-service/v1/account-service/accounts,Sign up (register)
GET,/v1/account-service/v1/account-service/accounts/:account_id/settings,


def wrapInQuotes(input: String): String = {
if (input.contains(SEPARATOR))
"\"" + input + "\""
Copy link
Collaborator

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?

Copy link
Collaborator Author

@mchimirev mchimirev Aug 13, 2019

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

Copy link
Collaborator

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"""

Copy link
Collaborator Author

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.

Copy link
Contributor

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

https://commons.apache.org/proper/commons-csv/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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

@mchimirev mchimirev force-pushed the endpionts-csv-generator branch 2 times, most recently from 40403a0 to 538d9c1 Compare August 13, 2019 19:32
@mchimirev mchimirev force-pushed the endpionts-csv-generator branch 2 times, most recently from 0e29c65 to b3a28f2 Compare August 14, 2019 16:02
@sullis sullis changed the title csv genrator csv generator Aug 14, 2019
@mchimirev mchimirev merged commit f3c781a into master Aug 15, 2019
@sullis sullis deleted the endpionts-csv-generator branch August 15, 2019 18:01
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

Successfully merging this pull request may close these issues.

4 participants