Home > Blockchain >  How to make convert return string in xlsx2csv?
How to make convert return string in xlsx2csv?

Time:11-01

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'])

CodePudding user response:


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

  • Related