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

Allow csv_path to be a file-like object as well #68

Closed
jonathan-s opened this issue Feb 3, 2018 · 3 comments
Closed

Allow csv_path to be a file-like object as well #68

jonathan-s opened this issue Feb 3, 2018 · 3 comments

Comments

@jonathan-s
Copy link
Contributor

Sometimes you don't have the CSV on disk but in memory. In instances like that it would be useful to be able to provide a file like object instead of first writing the csv to disk and then provide the path.

@jonathan-s jonathan-s changed the title Allow csv_path to actually be a file-like object Allow csv_path to be a file-like object as well Feb 3, 2018
@palewire
Copy link
Owner

palewire commented Feb 3, 2018

Do you see this as distinct from #25?

@jonathan-s
Copy link
Contributor Author

I had a look at that, and it looked like the person was suggesting a signature of CopyMapping in the following way CopyMapping(model=Entry, data=huge_list_of_unsaved_entries). Because of that signature suggestion I got unsure whether the author wanted something different than I did.

I wouldn't change the signature at all, instead I'd keep csv_path but check whether that argument is in fact a file-like object. If it is, I'd handle it as such.

If that sounds like an acceptable way of doing things, I'll submit something in the next few days.

@palewire
Copy link
Owner

palewire commented Feb 3, 2018

You're right, though if I understand it right the solution proposed lower down in the thread ultimately uses a StringIO object, which I presume is something similar to what you're thinking.

If that's right, your file object approach might provide a crucial building block to tackle that more complex "list of objects" challenge. If you have an idea, I say go for it!

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

2 participants