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

Newlines at end of strings are unexpected #336

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mo42
Copy link

@mo42 mo42 commented Nov 4, 2024

I'm reading a CSV file df.read("example.csv", io_format::csv2);:

INDEX:4:<ulong>,column2:4:<int>,string_col:4:<string>
0,0,string 0
1,1,string 1
2,2,string 2
3,3,string 3

In the data frame, I have newlines string 1\n for the last column, which might not match other columns not at the end. For example, when trying to join on string columns.

Implemented the logic that Unix-style and Windows-style newlines will be trimmed.

Comment on lines +1156 to +1161
if (!value.empty() && value.back() == '\n') {
value.pop_back();
}
if (!value.empty() && value.back() == '\r') {
value.pop_back();
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind to generalize this for csv and json formats as well? You can leave the binary format as is
Thanks

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sure. Will also check if I can add some test cases.

@hosseinmoein
Copy link
Owner

Also, please compile the build all binaries in the test subdirectory. And please run

dataframe_tester.cc
dataframe_tester_2.cc
dataframe_tester_3.cc
dataframe_tester_4.cc

They must all run without a problem

@mo42
Copy link
Author

mo42 commented Nov 13, 2024

They must all run without a problem

On the main branch, dataframe_tester_3 fails on an assert. I'm looking into this first.

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

Successfully merging this pull request may close these issues.

2 participants