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

The last line is ignored #151

Closed
Starfa opened this issue Mar 1, 2021 · 2 comments
Closed

The last line is ignored #151

Starfa opened this issue Mar 1, 2021 · 2 comments
Assignees
Labels

Comments

@Starfa
Copy link

Starfa commented Mar 1, 2021

example.csv
id,name
1,hello
2,""
Three lines in total.
Last line without line break.

I try to get all rows of this csv file. And i found the last line is ignored.

@Starfa
Copy link
Author

Starfa commented Mar 2, 2021

Can i fix it in this way?

CSV_INLINE void IBasicCSVParser::end_feed() {
using internals::ParseFlags;

    bool empty_last_field = this->data_ptr
        && this->data_ptr->_data
        && !this->data_ptr->data.empty()
        && (parse_flag(this->data_ptr->data.back()) == ParseFlags::DELIMITER
            || compound_parse_flag(this->data_ptr->data.back()) == ParseFlags::QUOTE_ESCAPE_QUOTE);

    // Push field
    if (this->field_length > 0 || empty_last_field) {
        this->push_field();
    }

    // Push row
    if (this->current_row.size() > 0)
        this->push_row();
}

@vincentlaucsb
Copy link
Owner

Thanks for your report. This was fixed in the latest commit.

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

No branches or pull requests

2 participants