easy-csv icon indicating copy to clipboard operation
easy-csv copied to clipboard

Using Reader to read and parse CSV strings

Open peter279k opened this issue 7 years ago • 5 comments

As title, is it possible to let the Reader class can parse the CSV strings instead of parsing the CSV file?

peter279k avatar Aug 30 '18 07:08 peter279k

@jwage, can you concern about this feature request if possible?

Thanks.

peter279k avatar Sep 03 '18 02:09 peter279k

It isn't possible right now but could be with a little refactoring.

jwage avatar Sep 03 '18 03:09 jwage

@jwage, thank you for your quick reply :+1:. Actually, I have to know this feature possibility. And I want to add this feature via PR if possible. I want to get some tips for developing this feature. I also need to use this feature for my project and I can help you to develop this.

Thank you for your concern again!

peter279k avatar Sep 03 '18 03:09 peter279k

So not sure what exactly I'm reading but I need a lawyer and a federal Marshall to take the issue out of my life.

Tigereyecdb avatar Sep 08 '21 21:09 Tigereyecdb

With minimum refactoring you can just rename $path as $path_or_content and then in initializeHandle if $mode is null (let's suppose we use this convention when $path_or_content is a string content not a path) you do :

$handle = new SplFileObject("php://memory", "w+");
$handle->fwrite($this->path_or_content);
$handle->rewind();

silviucpp avatar Dec 04 '21 22:12 silviucpp