Discussion:
Bug#977293: Read .xlsx from stdin, write .csv to stdout
(too old to reply)
Sebastien Hinderer
2020-12-13 17:20:02 UTC
Permalink
Package: xlsx2csv
Version: 1:0.7.6-1
Severity: wishlist
Tags: upstream

Dear upstream authors,

Many thanks for this very convenient tool.

Would it please be possible to extend is so that "-" ban be specified
both as the name of the input file (meaning to read the .xlsx file
from standard input) and as the name of the output file, meaning that
the CSV file is written to stdout?

That way the program could be used in a pipe, which would be very
convenient. Of course that requires to make sure that all the
other messages the program could possibly produce are writt
Sébastien Hinderer
2020-12-14 06:40:01 UTC
Permalink
Dear Andrius,

Many thanks for your prompt and helpful response!
Hello,
Post by Sebastien Hinderer
Dear upstream authors,
Debian is not the upstream of this package. Bug reports filed in Debian
BTS are not automatically forwarded to upstream either. To contact the
upstream, I suggest opening an issue on their GitHub issue tracker
[1].
My bad, sorry. Iwanted to write "dear maintainers" but while doing so I
was thinking that it was an upstream bug. My reason for submitting it as
a Debian bug was that I wanted to have a feedback not only in terms of
whether the feature can be included or not but also in terms of in which
version of the Debian package a fix would be included.
Post by Sebastien Hinderer
Would it please be possible to extend is so that "-" ban be specified
both as the name of the input file (meaning to read the .xlsx file
from standard input) and as the name of the output file, meaning that
the CSV file is written to stdout?
That way the program could be used in a pipe, which would be very
convenient. Of course that requires to make sure that all the
other messages the program could possibly produce are written to stderr.
Have you tried using /dev/stdin and /dev/stdout on the command line?
This usually does the trick for commands not accepting '-'.
No I didn't because, after almost 20 years of use of Unix, I was simply
not aware of the existence of these files! So, many thanks for making me
realise their existence!

Best wishes and thanks again, feel free to close the bug. If I submit an
issue I can always write back to link it with the present bug report.

Sébastien.
Sébastien Hinderer
2020-12-27 16:30:02 UTC
Permalink
Forwarded: https://github.com/dilshod/xlsx2csv/issues/213

Dear Andrius,
Have you tried using /dev/stdin and /dev/stdout on the command line?
This usually does the trick for commands not accepting '-'.
I tried finally and it does not work. It produces the following error:

Traceback (most recent call last):
File "/usr/bin/xlsx2csv", line 1129, in <module>
xlsx2csv.convert(outfile, sheetid)
File "/usr/bin/xlsx2csv", line 216, in convert
self._convert(sheetid, outfile)
File "/usr/bin/xlsx2csv", line 266, in _convert
outfile = open(outfile, 'w+', encoding=self.options['outputencoding'], newline="")
io.UnsupportedOperation: File or stream is not seekable.

Bug reported upstream at https://github.com/dilshod/xlsx2csv/issues/213

I did try to add the Forwarded: pseudo-header, I hope it worked.

Thanks,

Sébastien.
Sébastien Hinderer
2020-12-28 07:10:02 UTC
Permalink
Thanks a lot, Andrius.

Yes, I saw that the problem was the (non-)seakability of the file. Not
sure why this is needed, though.

And thanks a lot for having linked the bug report with the upstream
issue!

Sébastien.
Sébastien Hinderer
2020-12-28 13:20:02 UTC
Permalink
Actually,

xlsx2csv foo.xlsx

does write the CSV output on stdout.

I think this bug report can now be closed.

Thanks and sorry for the toruble.

Sébastien.
Andrius Merkys
2020-12-28 13:30:02 UTC
Permalink
Hi Sébastien,
Post by Sébastien Hinderer
Actually,
xlsx2csv foo.xlsx
does write the CSV output on stdout.
Glad the upstream answered your question.
Post by Sébastien Hinderer
I think this bug report can now be closed.
How about reading from stdin? Can you confirm that /dev/stdin does the
trick? If so, this bug report could indeed be closed.

Best,
Andrius
Sébastien Hinderer
2020-12-28 16:20:01 UTC
Permalink
Post by Andrius Merkys
Hi Sébastien,
Post by Sébastien Hinderer
Actually,
xlsx2csv foo.xlsx
does write the CSV output on stdout.
Glad the upstream answered your question.
Post by Sébastien Hinderer
I think this bug report can now be closed.
How about reading from stdin? Can you confirm that /dev/stdin does the
trick? If so, this bug report could indeed be closed.
Ye,s, I confirm that

xlsx2csv /dev/stdin < f.xlsx

produces the content of f.xlsx as a CSV on stdout.

Thanks again,

Sébastien.

Loading...