You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Ram (JIRA)" <ji...@apache.org> on 2008/08/26 04:49:44 UTC

[jira] Issue Comment Edited: (SANDBOX-210) Commons CSV EXCELL_STRATEGY is reading CSV files with double quote and comma properly but not writing them back the same way

    [ https://issues.apache.org/jira/browse/SANDBOX-210?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12625607#action_12625607 ] 

pcsri1956 edited comment on SANDBOX-210 at 8/25/08 7:49 PM:
------------------------------------------------------

This issue happens in CSVPrinter class. Here is how I fixed it. Look in the comment below where change is suggested specifically EXCEL_STRATEGY

private String escapeAndQuote(String value) {
.........    
          if (c == strategy.getEncapsulator()) {
        sb.append('"').append(c);                      // changed from  sb.append('\\').append(c);  
        continue;
................
      }
      }

      was (Author: pcsri1956):
    This issue happens in CSVPrinter class. Here is how I fixed it. Look in the comment below where change is suggested specifically EXCEL_STRATEGY

private String escapeAndQuote(String value) {
.........    
    StringBuffer sb = new StringBuffer(value.length() + count);
    sb.append(strategy.getEncapsulator());
    for (int i = 0; i < value.length(); i++) {
      char c = value.charAt(i);

      if (c == strategy.getEncapsulator()) {
        sb.append('"').append(c);                      // changed from  sb.append('\\').append(c);  
        continue;
      }
      switch (c) {
        case '\n' :
          sb.append("\\n");
          break;
        case '\r' :
          sb.append("\\r");
          break;
        case '\\' :
          sb.append("\\\\");
          break;
        default :
          sb.append(c);
      }
    }
    sb.append(strategy.getEncapsulator());
    return sb.toString();
  }

}
  
> Commons CSV EXCELL_STRATEGY is reading CSV files with double quote and comma properly but not writing them back the same way
> ----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: SANDBOX-210
>                 URL: https://issues.apache.org/jira/browse/SANDBOX-210
>             Project: Commons Sandbox
>          Issue Type: Bug
>          Components: CSV
>            Reporter: Ilya Egoshin
>
> original line: My line is containing ", symbols
> line in CSV file after "Save as CSV" in Excell: "My line containing "", symbols"
> line is CSV file as output from CSVPrinter with EXCELL_STRATEGY: "My line containing \", symbols"
> as a result when you will try to open that file in the excell you see text inside two cells:
> 1 cell: My line containing \
> 2 cell: symbols
> is it again Microsoft "features", that are "improving" RFC?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.