Skip to content
This repository has been archived by the owner on Feb 9, 2022. It is now read-only.

Commit

Permalink
Written spectra export function
Browse files Browse the repository at this point in the history
  • Loading branch information
ggirelli committed Jun 14, 2019
1 parent f72a6aa commit 0408146
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions app/src/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,22 @@ read_spectra = function(spath) {

return data2;
}

write_spectra = function(data, fname) {
// Write spectra from settings to file
var filename = dialog.showSaveDialog(null, {
title: "Export spectra",
defaultPath: fname
});

var content = "w\tri\n";
for (var i = 0; i < data.w.length; i++)
content = content + data.w[i] + "\t" + data.ri[i] + "\n";

try {
fs.writeFileSync(filename, content, 'utf-8');
toastr.success("Spectra exported to '" + filename + "'");
} catch(e) {
toastr.danger('Failed to export the spectra to "', filename, '"!');
}
}

0 comments on commit 0408146

Please sign in to comment.