[ 
https://issues.apache.org/jira/browse/CSV-171?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15399148#comment-15399148
 ] 

Adrian Bridgett commented on CSV-171:
-------------------------------------

I wonder if that newRecord rule is a poorer version of the rule higher up that 
ensures that if there is only one single column that it is quoted.
Completely agree that it'd be really helpful if this worked correctly with 
negative numbers in particular as this causes problems when e.g. writing out a 
CSV file and then attempting to import it as some systems take the quotes as 
forcing it to be a string. 

> Negative numeric values in the first column are always quoted in minimal mode
> -----------------------------------------------------------------------------
>
>                 Key: CSV-171
>                 URL: https://issues.apache.org/jira/browse/CSV-171
>             Project: Commons CSV
>          Issue Type: Bug
>            Reporter: Michael Graessle
>            Priority: Minor
>
> Negative Numeric values are always quoted in minimal mode if (and only if) 
> they are in the first column.
> i.e.
> long,lat,data
> "-92.222",43.333,3
> Looking at the code, this is by design but seem to be for an unknown reason.
> From v1.2 CSVPrinter line 230:
> // TODO where did this rule come from?
> if (newRecord && (c < '0' || (c > '9' && c < 'A') || (c > 'Z' && c < 'a') || 
> (c > 'z'))) {
>     quote = true;
> } else ...
>    
> I propose this rule to either be remove or at a minimum be changed to:
> // TODO where did this rule come from?
> if (newRecord && (c !='-' && c < '0' || (c > '9' && c < 'A') || (c > 'Z' && c 
> < 'a') || (c > 'z'))) {
>     quote = true;
> } else ...
>    



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to