public static File performExternal2Bin(File sourceFile, File targetFile, TaskComplete done) {
File binaryFile = targetFile;
DialogExternal2Binary dialog = new DialogExternal2Binary(EncogWorkBench
.getInstance().getMainWindow());
if (binaryFile != null) {
dialog.getBinaryFile().setValue(binaryFile.toString());
}
if( sourceFile!=null ) {
dialog.getExternalFile().setValue(sourceFile.toString());
}
if (dialog.process()) {
binaryFile = new File(dialog.getBinaryFile().getValue());
File externFile = new File(dialog.getExternalFile().getValue());
int fileType = dialog.getFileType().getSelectedIndex();
int inputCount = dialog.getInputCount().getValue();
int idealCount = dialog.getIdealCount().getValue();
// no extension
if (ExtensionFilter.getExtension(binaryFile) == null) {
binaryFile = new File(binaryFile.getPath() + ".egb");
}
DataSetCODEC codec;
BinaryDataLoader loader;
if (fileType == 0) {
DialogCSV dialog2 = new DialogCSV(EncogWorkBench.getInstance()
.getMainWindow());
if (dialog2.process()) {
boolean headers = dialog2.getHeaders().getValue();
CSVFormat format;
if (dialog2.getDecimalComma().getValue())
format = CSVFormat.DECIMAL_COMMA;
else
format = CSVFormat.DECIMAL_POINT;
codec = new CSVDataCODEC(externFile, format, headers,
inputCount, idealCount, dialog.getContainsSignificance().getValue());
loader = new BinaryDataLoader(codec);
ImportExportDialog dlg = new ImportExportDialog(loader,
binaryFile, true);
dlg.process(done);
}