dilshod / xlsx2csv

Convert xslx to csv, it is fast, and works for huge xlsx files
MIT License
1.64k stars 302 forks source link

How to make convert return string? #243

Closed Gaoyongxian666 closed 1 year ago

Gaoyongxian666 commented 1 year ago

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

Gaoyongxian666 commented 1 year ago
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())