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

Fix: handle extra double quotes when empty value #13

Merged
merged 2 commits into from
Feb 7, 2019

Conversation

iliasbhal
Copy link
Contributor

@iliasbhal iliasbhal commented Feb 6, 2019

Issue

CSV wasn't handling this edge case correctly

http://transitupdateui.transitapp.com/notices/e28c03ed858a4128dd37ed1d6c1b5636

What has been done

  • added a new case to the switch-like statement

Example

  • will transform:
    1,"MB9","Broad St / Lincoln St","""""",42.343861898414,-71.5629380382858,0

  • to :
    1,"MB9","Broad St / Lincoln St","",42.343861898414,-71.5629380382858,0

  • instead of :
    1,"MB9","Broad St / Lincoln St",\"\\\",42.343861898414,-71.5629380382858,0

@gcamp
Copy link
Member

gcamp commented Feb 6, 2019

Not even sure what is the correct behaviour in that case, should that really be transformed to ""?

@iliasbhal
Copy link
Contributor Author

iliasbhal commented Feb 6, 2019

@gcamp Are you talking about empty strings vs empty cells? ,"", vs ,,

will remove all extra pair of double quotes and escape only 2 double quotes
@iliasbhal
Copy link
Contributor Author

iliasbhal commented Feb 7, 2019

@gcamp now it will remove all extra double-quotes and escape 2 double quotes.

new behavior:

  • from string:
    1,"MB9","Broad St / Lincoln St","""""",42.343861898414,-71.5629380382858,0

  • to string :
    1,"MB9","Broad St / Lincoln St","\\"\\"",42.343861898414,-71.5629380382858,0

  • in JS, il will appear as "" when evaluated.
    [ 1, 'MB9', 'Broad St / Lincoln St' , '""' , 42.343861898414 , -71.5629380382858 0]

RFC link : https://tools.ietf.org/html/rfc4180

@iliasbhal iliasbhal merged commit b30f1eb into master Feb 7, 2019
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