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

Fix csv parsing #531

Merged
merged 7 commits into from
Oct 27, 2021
Merged

Fix csv parsing #531

merged 7 commits into from
Oct 27, 2021

Conversation

Vindaar
Copy link
Collaborator

@Vindaar Vindaar commented Oct 26, 2021

This is not really related to #530. In addition to that issue the parsing of CSV files has been broken by the laser backend PR, due to the change away from the Fdata field name. That name was still in use for the CSV parser.

While changing this I stumbled over some issues with how to handle the parsing now. Due to having non seq[T] based tensors for mem copyable types, we would have to always copy from the parsed seq[T] data to a tensor. I thought the better solution would be to instead walk the file once first to determine the number of lines and columns and then already construct an appropriate tensor. Then just fill it in a second pass using the CSV parser. Ideally, we should parse directly using the memfiles interface, but that's a lot more work.

From the datamancer CSV parser (which uses memfiles) I know that checking for line count before starting to parse is fast enough (it pays off compared to reallocations).

@Vindaar
Copy link
Collaborator Author

Vindaar commented Oct 26, 2021

Ugh, I just realized I forgot to take quoting into account for the counting of lines. That makes the code a bit more annoying as we then have to check each character, check if we find a quote, disable line counting in the quote and disable at the next quote etc...

@Vindaar Vindaar merged commit 649e42b into mratsim:master Oct 27, 2021
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.

1 participant