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

Escape quotation mark in application when exporting to csv #411

Merged
merged 2 commits into from
Nov 4, 2021

Conversation

juniwbjerde
Copy link
Member

@juniwbjerde juniwbjerde commented Oct 11, 2021

Solves #397

I've changed so that all " in user input texts are replaced with ' when exporting to csv. This solves the problem we had when exporting the csv, since the ' in the application text won't be confused with the " used as the enclosing character for the csv fields (which was the problem before).

PS: Comma is still the separator used in the csv file, but I did not bother to replace all commas with anything, as the problem arises when you have a combination of " and , and it is read as the and of one field and then a seperator and then the start of another. Having just commas in the application texts should not be a problem as long as they're not paired with " (and vise versa, but i figured it would be less of a problem to replace " with ' than to find something to replace all commas with)

@juniwbjerde juniwbjerde changed the title [WIP] Escape quotation mark in application when exporting to csv Escape quotation mark in application when exporting to csv Nov 2, 2021
Copy link
Member

@SmithPeder SmithPeder left a comment

Choose a reason for hiding this comment

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

The idea is good.

But maybe make this into a util function, then reuse that function.

export const prepare(text) => text.replaceAll('"', "'")

This function could also have a default return like "Empty TextField" or something, so you don't need a big turnery in the setState.

@LudvigHz LudvigHz merged commit 078fb0d into master Nov 4, 2021
@LudvigHz LudvigHz deleted the fix-csv-export branch November 4, 2021 13:27
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.

3 participants