[JAMESII-368] Enhance CSVWriter handling of 2D arrays of primitives Created: 09/Jul/13  Updated: 13/Sep/13  Resolved: 13/Sep/13

Status: Resolved
Project: James II
Component/s: None
Affects Version/s: None
Fix Version/s: James II 0.9.3
Security Level: public (Visible to EVERYONE.)

Type: Improvement Priority: Minor
Reporter: Stefan Rybacki Assignee: re027
Resolution: Fixed Votes: 0
Labels: output
Remaining Estimate: 0 minutes
Time Spent: Not Specified
Original Estimate: 0 minutes

Attachments: Zip Archive mylyn-context.zip    

 Description   

The problem is that calling CSVWriter#writeResult with, for example, a double[][] will write a single line with the double[] toString output, instead of the whole matrix (as would be expected).



 Comments   
Comment by re027 [ 10/Jul/13 ]

To reduce redundancy (the many writeResult(...) functions with different signatures) I am going to change CSVWriter from a utility singleton (containing only static methods) to a class with state, so that default parameters (delimiter etc.) can be set in the constructor(s).

Comment by re027 [ 13/Sep/13 ]

To avoid code duplication, several public methods have been removed from CSVWriter, e.g. all methods to append data to an existing file.

To do so, you can now use org.jamesii.core.util.misc.Files#appendToFiles, which can be easily combined with the CSVWriter, for example:

Files.appendToFile("my.csv", CSVWriter.toCSV(results, ',').toString());

Additionally, the (seemingly unused?) method to store 1D arrays has been removed. This avoids to accidentally pass a 2D primitive array into it, although it cannot handle it.

Also, note that only the fully-configurable CSVWriter#writeResult(...) method is now available for 2D arrays of the eight primitive data types, to avoid code duplication.

Generated at Thu Apr 25 05:53:05 CEST 2019 using JIRA 5.0.7#734-sha1:8ad78a62c71cf08b03545eb446cc3b9bb5ce37ad.