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

Support csv import #124

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

AndrooFrowns
Copy link

Implement basic changes to permit CSV files to be converted to .ic

Modified paste csv function to not use a &str so that the data doesn't need to be entirely in memory, hopefully permitting large CSVs to be read.

not addressed yet, but noticed while implementing:

  • export to CSV
  • user/programmatic selection of CSV settings
  • supporting strings rather than chars for comment indicator

@AndrooFrowns
Copy link
Author

It looks like I thought BufReader would permit partially reading a file in chunks to permit reading files larger than available RAM. It looks like the more correct way to handle that is with mmap or manually writing the code to read in chunks.

I could try to switch strategies here or just make that a future enhancement, up to you.

@nhatcher
Copy link
Member

I could try to switch strategies here or just make that a future enhancement, up to you.

There is not a time constraint, if you think there is a better way, go for the better way.

FileKind::Csv => handle_csv(&path),
}?;

save_to_icalc(&model, &output_path).with_context(|| "Failed to sasve file as .icalc")?;

Choose a reason for hiding this comment

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

I thought the extension was .ic.

Copy link
Author

Choose a reason for hiding this comment

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

That might be, I just kept what this file was using. Is there a standard naming convention we should ensure is used everywhere?

use std::process::{Command, ExitStatus};

#[test]
fn test_simple_csv() {

Choose a reason for hiding this comment

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

There are a huge number of edge cases in CSV files that you'll want to test. Escaped (or unescaped) commas inside strings, function calls, misaligned column count, etc.

Copy link
Author

Choose a reason for hiding this comment

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

This is a good point, however as I'm relying on the implementation we already have for copy/paste purposes, I tried to stay focused the parts relating to getting a file in rather than improving the csv parsing itself.

If it's a blocker I can add it as well when I get time to work on this, but the distinction made sense in my head.

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.

3 participants