csv icon indicating copy to clipboard operation
csv copied to clipboard

Read StringIO with foreach

Open MarcPer opened this issue 1 year ago • 2 comments

Proposal

I'd like to propose being able to open a StringIO s with CSV.foreach(s), just as it's possible to open a file with CSV.foreach(path).

I can investigate and open a PR if this behavior is desired.

Current behavior

The documentation already says it should be possible to pass an IO object to foreach, but if an instance of StringIO is passed, we get:

no implicit conversion of StringIO into String (TypeError)

MarcPer avatar May 03 '24 14:05 MarcPer

If CSV.foeach(io) works, CSV.foreach(string_io) should work too.

kou avatar May 03 '24 15:05 kou

Great, I'll open a PR with proposed changes in the next days.

MarcPer avatar May 03 '24 16:05 MarcPer