Python win32 how to save xls as csv?

I download .xlsx from win32com and would like to save the results as csv when done.

myworkbook.SaveAs('results.csv')

gives me an xlsx file with the csv extension. How to save as actual CSV?

+3
source share
4 answers

I think that if you add a type after the file name, it should work. (Can’t check right now.)

I think the type for CSV (DOS) is 24.

myworkbook.SaveAs('results.csv', 24)
+3
source

Here are the docs for saveAs: http://msdn.microsoft.com/en-us/library/bb214129.aspx

from win32com.client import constants as c
myWorkBook.SaveAs('results.csv', c.xlCSV)
+2
source

.

CSV :

xlCSV = 6         # Comma separated value.
xlCSVMac = 22,    # Comma separated value.
xlCSVMSDOS = 24,  # Comma separated value.
xlCSVWindows =23, # Comma separated value.

, saveAs . python, .

+1

All Articles