-
Notifications
You must be signed in to change notification settings - Fork 7
Exporting Data
vstarlinger edited this page Aug 29, 2017
·
2 revisions
Exporting data is done in the ExportController class. Currently only export to csv files is supported. Exporting can be done by calling the static saveDataAsCSV(Data data, File f, boolean saveRaw) method.
This method requires the follwing inputs:
- Data: data that should be stored
- f - File: File that the data should be saved to
- saveRaw - boolean: specifies whether the DataModification.adjustSensor method should be used to adjust the sensor data before it is saved.
The method then saves the data to a csv file, using the variable names saved in the data for column titles and the Long keys in the variables TreeMap to sort the entries.
Example of how to implement the method:
public void exportCSV() {
FileChooser fc = new FileChooser();
fc.setTitle("Export .csv");
File selectedFile = fc.showSaveDialog(stage);
if (selectedFile != null) {
try {
ExportController.saveDataAsCSV(messageController.getData(), selectedFile, false);
} catch (IOException ex) {
System.out.println("something wrong happend when saving the file");
}
}
}