How to make convert return string in xlsx2csv?

Question:

https://github.com/dilshod/xlsx2csv

This project has only one file, which looks easy to understand, but I don’t know how to modify it so that it outputs the result string instead of directly inputting it into the file.

I want it not to output to a file, but to return a string. But I can’t understand the code. How should I modify it

writer = csv.writer(outfile, quoting=self.options['quoting'], delimiter=self.options['delimiter'],

lineterminator=self.options['lineterminator'])

Asked By: 高永献

||

Answers:


output = io.StringIO()
Xlsx2csv(r"C:UsersGaoyongxianPycharmProjectsY_searcherdemo.xlsx", outputencoding="utf-8").convert(output,0)
with open("demo.txt","w",encoding="utf8") as f:
    print(output.getvalue())
    f.write(output.getvalue())

Answered By: 高永献
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.