[ 
https://issues.apache.org/jira/browse/CSV-211?focusedWorklogId=434353&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-434353
 ]

ASF GitHub Bot logged work on CSV-211:
--------------------------------------

                Author: ASF GitHub Bot
            Created on: 18/May/20 09:33
            Start Date: 18/May/20 09:33
    Worklog Time Spent: 10m 
      Work Description: dota17 opened a new pull request #71:
URL: https://github.com/apache/commons-csv/pull/71


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

            Worklog Id:     (was: 434353)
    Remaining Estimate: 0h
            Time Spent: 10m

> CSVFormat.format trims last delimiter if the delimiter is a white space
> -----------------------------------------------------------------------
>
>                 Key: CSV-211
>                 URL: https://issues.apache.org/jira/browse/CSV-211
>             Project: Commons CSV
>          Issue Type: Bug
>    Affects Versions: 1.4
>         Environment: Any.
>            Reporter: Alpesh Kulkarni
>            Priority: Minor
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> The function CSVFormat.format() trims off the last delimiter if the delimiter 
> is a white space character and the value in the last column is null.
> {code:java}
>     public String format(Object... values) {
>         StringWriter out = new StringWriter();
>         try {
>             (new CSVPrinter(out, this)).printRecord(values);
>             return out.toString().trim();
>         } catch (IOException var4) {
>             throw new IllegalStateException(var4);
>         }
>     }
> {code}
> For example, consider the following records (\t = tab)-
> ID{color:red}\t{color}Name{color:red}\t{color}Country{color:red}\t{color}Age
> 1{color:red}\t{color}John Doe{color:red}\t{color}USA{color:red}\t{color}20
> 2{color:red}\t{color}Jane Doe{color:red}\t{color}USA{color:red}\t{color}
> The CSVFormat.format() on both the rows returns the following -
> ID{color:red}\t{color}Name{color:red}\t{color}Country{color:red}\t{color}Age
> 1{color:red}\t{color}John Doe{color:red}\t{color}USA{color:red}\t{color}20
> 2{color:red}\t{color}Jane Doe{color:red}\t{color}USA
> Note that there is a missing delimiter for the last column in the second 
> record.
> This usually causes schema mismatch when we try and read back the CSV file as 
> there is one less column in all the rows which have a null at the end.
> I feel the trim() is unnecessary while returning *out.toString()*



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to