use of com.univocity.parsers.fixed.FixedWidthWriterSettings in project tablesaw by jtablesaw.
the class FixedWidthWriter method fixedWidthWriterSettings.
protected FixedWidthWriterSettings fixedWidthWriterSettings(FixedWidthWriteOptions options) {
FixedWidthWriterSettings settings = new FixedWidthWriterSettings();
if (options.columnSpecs() != null) {
settings = new FixedWidthWriterSettings(options.columnSpecs());
}
if (options.autoConfigurationEnabled()) {
settings.setAutoConfigurationEnabled(options.autoConfigurationEnabled());
} else {
columnRowSettings(settings, options);
errorSettings(settings, options);
skipIgnoreSettings(settings, options);
}
return settings;
}
use of com.univocity.parsers.fixed.FixedWidthWriterSettings in project powsybl-core by powsybl.
the class IeeeCdfWriter method writeRecords.
private static <T> void writeRecords(Writer writer, List<T> beans, Class<T> aClass) {
FixedWidthWriterSettings settings = new FixedWidthWriterSettings();
settings.setWriteLineSeparatorAfterRecord(true);
BeanWriterProcessor<T> processor = new BeanWriterProcessor<>(aClass);
settings.setRowWriterProcessor(processor);
new FixedWidthWriter(writer, settings).processRecords(beans);
}
use of com.univocity.parsers.fixed.FixedWidthWriterSettings in project tablesaw by jtablesaw.
the class FixedWidthWriter method write.
public void write(Table table, FixedWidthWriteOptions options) {
FixedWidthWriterSettings settings = fixedWidthWriterSettings(options);
settings.setFormat(fixedWidthFormat(options));
com.univocity.parsers.fixed.FixedWidthWriter fixedWidthWriter = null;
// Creates a writer with the above settings;
try {
Writer writer = options.destination().createWriter();
fixedWidthWriter = new com.univocity.parsers.fixed.FixedWidthWriter(writer, settings);
if (options.header()) {
String[] header = new String[table.columnCount()];
for (int c = 0; c < table.columnCount(); c++) {
header[c] = table.column(c).name();
}
fixedWidthWriter.writeHeaders(header);
}
for (int r = 0; r < table.rowCount(); r++) {
String[] entries = new String[table.columnCount()];
for (int c = 0; c < table.columnCount(); c++) {
table.get(r, c);
entries[c] = table.getUnformatted(r, c);
}
fixedWidthWriter.writeRow(entries);
}
} finally {
if (fixedWidthWriter != null) {
fixedWidthWriter.flush();
if (options.autoClose())
fixedWidthWriter.close();
}
}
}
use of com.univocity.parsers.fixed.FixedWidthWriterSettings in project symja_android_library by axkr.
the class FixedWidthWriter method write.
public void write(Table table, FixedWidthWriteOptions options) {
FixedWidthWriterSettings settings = fixedWidthWriterSettings(options);
settings.setFormat(fixedWidthFormat(options));
com.univocity.parsers.fixed.FixedWidthWriter fixedWidthWriter = null;
// Creates a writer with the above settings;
try {
Writer writer = options.destination().createWriter();
fixedWidthWriter = new com.univocity.parsers.fixed.FixedWidthWriter(writer, settings);
if (options.header()) {
String[] header = new String[table.columnCount()];
for (int c = 0; c < table.columnCount(); c++) {
header[c] = table.column(c).name();
}
fixedWidthWriter.writeHeaders(header);
}
for (int r = 0; r < table.rowCount(); r++) {
String[] entries = new String[table.columnCount()];
for (int c = 0; c < table.columnCount(); c++) {
table.get(r, c);
entries[c] = table.getUnformatted(r, c);
}
fixedWidthWriter.writeRow(entries);
}
} finally {
if (fixedWidthWriter != null) {
fixedWidthWriter.flush();
if (options.autoClose())
fixedWidthWriter.close();
}
}
}
use of com.univocity.parsers.fixed.FixedWidthWriterSettings in project symja_android_library by axkr.
the class FixedWidthWriter method fixedWidthWriterSettings.
protected FixedWidthWriterSettings fixedWidthWriterSettings(FixedWidthWriteOptions options) {
FixedWidthWriterSettings settings = new FixedWidthWriterSettings();
if (options.columnSpecs() != null) {
settings = new FixedWidthWriterSettings(options.columnSpecs());
}
if (options.autoConfigurationEnabled()) {
settings.setAutoConfigurationEnabled(options.autoConfigurationEnabled());
} else {
columnRowSettings(settings, options);
errorSettings(settings, options);
skipIgnoreSettings(settings, options);
}
return settings;
}
Aggregations