Skip to content

Less aggressive quoting#35

Open
mightybyte wants to merge 2 commits into
ozataman:masterfrom
mightybyte:less-aggressive-quoting
Open

Less aggressive quoting#35
mightybyte wants to merge 2 commits into
ozataman:masterfrom
mightybyte:less-aggressive-quoting

Conversation

@mightybyte

Copy link
Copy Markdown
Collaborator

Currently csv-conduit outputs the string "" for empty fields. Postgres throws the following error when it encounters this for fields of type double precision:

ERROR:  invalid input syntax for type double precision: ""

So while the current behavior is correct according to the spec, it seems to be less broadly supported in practice. Also, if you're using csv-conduit to transform large files, the current behavior means that every single field will be quoted. This means that you're outputting two additional bytes per field, making the resulting files noticeably larger than they need to be.

This PR only quotes fields if they contain the quote character, which is correct behavior according to the spec.

Comment thread csv-conduit.cabal
, mmorph
, primitive
, resourcet >= 1.1.2.1
, resourcet >= 1.1.2.1 && < 1.2

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I also noticed that csv-conduit does not build with resourcet-1.2, so I added this upper bound.

@MichaelXavier

Copy link
Copy Markdown
Collaborator

I don't know if I can justify changing the behavior for all users here. I think I'd prefer adding a flag to CSVSettings, something like data OutputQuoting = AlwaysQuote | QuoteWhenNeeded and have the default continue to be AlwaysQuote.

@mightybyte

Copy link
Copy Markdown
Collaborator Author

Ahh yes, good idea. I'll try to get to it when I have some free time.

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.

2 participants