base_path = os.path.dirname(os.path.abspath(__file__))
_csvFilename = os.path.join(base_path, "bcForecasting.csv")
_csvFile = open (_csvFilename, 'wb')
_csvFile = csv.writer(_csvFile, quoting=csv.QUOTE_ALL)
_Header = self.makeIntoList (self.root.tss.series () [0].getAllTimes (), self.originalTimesteps + _futurePeriods)
_csvFile.writerow (_Header)
Now I want to open the created bcForecasting.csv
file in Excel. How to do it in Python?
Usually on Windows the .csv
filetype is configured to be opened by Excel. In this case you can just do:
from subprocess import Popen
p = Popen('filename.csv', shell=True)
In case it does not work, try pointing the full path of the Excel application:
subprocess.Popen(r'C:\Program Files (x86)\Microsoft Office\Office14\EXCEL.EXE stack.csv')
You can use the 'startfile' command from the os library.
import os
os.startfile('filename.csv')
Do make sure to specify the path of the file or to set the working directory to the path where the file is located.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With