spout icon indicating copy to clipboard operation
spout copied to clipboard

Is it possible to use wb instead of wb+ fopen mode in openToFile() in AbstractWriter in order to use compress.zlib:// ?

Open cmanley opened this issue 2 years ago • 5 comments

If I try to write to a compressed CSV file, then I get an exception using the file wrapper compress.zlib://

I think it has to do with the seekable file mode used here: $this->filePointer = $this->globalFunctionsHelper->fopen($this->outputFilePath, 'wb+');

Simply removing the + from the file mode seems to solve the problem but I'm not sure if box/spout needs it somewhere for something.

B.t.w. this is the exception and errors I get when I open a file with a compress.zlib wrapper using the latest v2 release:

PHP Warning:  fopen(compress.zlib://art.csv.gz): failed to open stream: operation failed in lib/box/spout/src/Spout/Common/Helper/GlobalFunctionsHelper.php on line 25
PHP Fatal error:  Uncaught Box\Spout\Common\Exception\IOException: File pointer has not be opened in lib/box/spout/src/Spout/Writer/AbstractWriter.php:175

cmanley avatar Mar 30 '22 20:03 cmanley

Fix merged in https://github.com/openspout/openspout/pull/66 and released in openspout:v3.7.4

Slamdunk avatar Mar 31 '22 06:03 Slamdunk

Thanks! Is it possible to merge it into the 2.* branch too?

On 2022-03-31 08:16, Filippo Tessarotto wrote:

Fix merged in openspout/openspout#66 https://github.com/openspout/openspout/pull/66 and released in |openspout:v3.7.4| https://github.com/openspout/openspout/releases/tag/v3.7.4

— Reply to this email directly, view it on GitHub https://github.com/box/spout/issues/881#issuecomment-1084140698, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEQLNKWYC5U2UMMCT6MJ3DVCU7MLANCNFSM5SDEYI7Q. You are receiving this because you authored the thread.Message ID: @.***>

cmanley avatar Mar 31 '22 06:03 cmanley

There's no branch 2.x in the community fork I'm maintaining at https://github.com/openspout/openspout, sorry

Slamdunk avatar Mar 31 '22 06:03 Slamdunk

If you need a backport, I suggest leveraging https://github.com/cweagans/composer-patches

Slamdunk avatar Mar 31 '22 06:03 Slamdunk

Alright thanks. I only just noticed that the patch was in openspout. That's new to me.

cmanley avatar Mar 31 '22 06:03 cmanley