commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebb (Commented) (JIRA)" <>
Subject [jira] [Commented] (CSV-54) Confusing semantic of the ignore leading/trailing spaces parameters
Date Fri, 23 Mar 2012 15:19:28 GMT


Sebb commented on CSV-54:

Definitely better to drop the separate leading/trailing space options.

However, I think "interleavedSpacesIgnored" should apply for both quoted and unquoted values.
As far as I can tell, that is the expectation in the CSV format specs I've seen.

The "trimmedSpaces" setting would then be identical to "interleavedSpacesIgnored" for unquoted
For quoted values it would also trim the enclosed value; not sure that's particularly useful
to provide as part of CSV.
It's easy enough for the application to trim the fields, so I'm not sure the setting is necessary.
Seems like it is straying away from the basic purpose of CSV.

However, if/when CSV is updated support creating Java Beans, value trimming would be much
more appropriate there, as it would be on a per-column basis.

Let's keep the initial parsing simple.
> Confusing semantic of the ignore leading/trailing spaces parameters
> -------------------------------------------------------------------
>                 Key: CSV-54
>                 URL:
>             Project: Commons CSV
>          Issue Type: Bug
>          Components: Parser
>            Reporter: Emmanuel Bourg
>             Fix For: 1.0
> {{CSVFormat}} has two parameters to control how the leading and trailing spaces around
values are handled, but the actual behavior depends on the value being enclosed in quotes
or not.
> If the value is not enclosed in quotes, setting {{leading/trailingSpacesIgnored}} to
{{true}} will left or right trim the value. For example with this input (using the default
> {code}a,  b  ,c{code}
> the second value will be equal to {{'b'}}.
> But if the value is enclosed into quotes, the value is no longer trimmed:
> {code}a," b ",c{code}
> this will give {{' b '}}.
> With quoted values the parser actually ignores the spaces between the delimiter and the
quote. Thus with this input:
> {code}a, " b " ,c{code}
> The value returned is {{' b '}}.
> If {{leading/trailingSpacesIgnored}} is set to {{false}}, we get instead {{' " b " '}}
which is consistent with RFC 4180.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message