file module issues with excel format

Advertisements

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?

>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.

Leave a ReplyCancel reply