Does anyone have anything handy lying around to export some String data to a .csv file ?
I’ve got a TableListBox which is basically a three column table acting as a very basic confusion matrix/result-plot for a classification algorithm. Showing the actual class/label of an instance in a test data set vs the class/label predicted by the classifier when fed with the test instance.
Column 1 is just displays and index/count from 1 - N where N is the number of table rows or instances in the test set.
Column 2 shows the “actual” class corresponding to the class/label of the test instance.
Column 3 shows the “predicted” class corresponding to the class/label predicted by the classifier for the instance.
The values in the cells for the “actual” and “predicted columns” are just Strings.
Like so:
Instance Actual Predicted
1 Kick Kick
2 Kick Snare
Does anyone have an example of exporting this out to a .csv ?
Probably ought to sit and work it out but If the fine JUCE folk have any snippets lying around…well, times a wastin.
Use OutputStream::writeText(). Just iterate through each item in the Table – the best methodology is to have an OwnedArray of objects which are listed in your Table… then when you need to export them simply have an export method which iterates through the OwnedArray and have a method in the object class which returns a comma separated String
Just a heads-up that that pseudo-code is probably overcomplicated and would actually do the wrong thing depending on the arguments you pass to writeText().
You only need something as simple as
File f = getYourFile();
f.deleteFile();
for (auto thing : yourThings)
f << thing.item1 << "\t" << thing.item2 << "\t" << thing.item3 << newLine;