Skip to content

Output in fixed width format fail, FixedWidthWriterSettings.fieldLengths is always null #942

@Kerwinooooo

Description

@Kerwinooooo

I have problen when I try to output the table in fixed width format in these two ways:

double[] v1 = {1, 2, NaN};
double[] v2 = {1, 2, NaN};
Table table = Table.create("table", DoubleColumn.create("v1", v1), DoubleColumn.create("v2", v2));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
FixedWidthWriteOptions options =
        new FixedWidthWriteOptions.Builder(baos).build();
FixedWidthWriter writer = new FixedWidthWriter();
writer.write(table, options);

and

double[] v1 = {1, 2, NaN};
double[] v2 = {1, 2, NaN};
Table table = Table.create("table", DoubleColumn.create("v1", v1), DoubleColumn.create("v2", v2));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
FixedWidthFields fwf = new FixedWidthFields(10, 10);
FixedWidthWriteOptions options =
        new FixedWidthWriteOptions.Builder(baos)
                .autoConfigurationEnabled(false)
                .header(fwf)  // this function set the value to FixedWidthWriteOptions.columnSpecs
                .build();
FixedWidthWriter writer = new FixedWidthWriter();
writer.write(table, options);

I found that FixedWidthWriterSettings.fieldLengths is always null, and FixedWidthFields.columnSpecs inputted by user is not assigned to FixedWidthWriterSettings.fieldLengths. I plan to assign the value to FixedWidthWriterSettings.fieldLengths in FixedWidthWriter.fixedWidthWriterSettings().

If the solution is acceptable, I would like to pull a request to fix it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions