Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

file module issues with excel format

my goal is to write result into single excel file,here is simple code :

import  numpy_financial as npf
Present =2000
period =20
rate =0.12
pmt =abs(npf.pmt(rate/12,period*12,Present))
print(pmt)
import  csv
file =open("Result.xlsx",'w')
file =  csv.writer(file)
file.writerow([pmt])

as a outcome -Result.xlsx is created, but i can’t open, if i change xlsx extension to csv , then it works fine, i know , that there is another library called as xlsxwriter , but just for shake of curiosity , does csv module supports xlsx extensions? am i missing something?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

No, the csv module does not support xlsx extensions. Here is a quote from the documentation I linked:

The csv module implements classes to read and write tabular data in
CSV format

The documentation does not mention support for writing xlsx.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading