Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tablesaw seriliaze null String values #1221

Open
yelizgungor opened this issue Jul 6, 2023 · 7 comments
Open

Tablesaw seriliaze null String values #1221

yelizgungor opened this issue Jul 6, 2023 · 7 comments

Comments

@yelizgungor
Copy link

yelizgungor commented Jul 6, 2023

While serializing the tablesaw structure to a CSV string, I used CsvWriter and noticed that the default nullValue is being used as an empty string. To set a specific string, such as "__null_rep" or "__na_rep", I need to set the nullValue parameter with CsvWriteOptions. This is similar to the na_rep parameter used in the Python Pandas DataFrame to_csv method for serialization.

Table table = createNewTable();
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
CsvWriteOptions options = CsvWriteOptions.builder(byteArrayOutputStream)
            .header(true)
            .build();
 new CsvWriter().write(table, options)
 return byteArrayOutputStream.toByteArray();
@frankwondon
Copy link

frankwondon commented Jul 6, 2023 via email

@lwhite1
Copy link
Collaborator

lwhite1 commented Jul 6, 2023 via email

@yelizgungor
Copy link
Author

Yup, I will do that as you suggest in this issue. But it would be good to have a setting for that.
Thanks for response, @lwhite1

@lwhite1
Copy link
Collaborator

lwhite1 commented Jul 6, 2023 via email

@yelizgungor
Copy link
Author

I updated the StringColumns formatter. But it seems CsvWriter calls getUnformattedString instead getString

@yelizgungor
Copy link
Author

But AFAIS there is another main problem: There is no differentiation for StringColumn between an empty string and a null value to define if it isMissing

@lwhite1
Copy link
Collaborator

lwhite1 commented Jul 6, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants