I want to open a file using the subprocess
module as though the file was double-clicked in Explorer. How do I do that?
I tried the following line:
subprocess.call("C:/myfile.csv", shell=True)
which throws an error saying:
The syntax of the command is incorrect.
'C:\' is not recognized as an internal or external command, operable program or batch file.
How do I emulate a double-click using subprocess
? Basically I want to open a CSV file in Excel 2007.
subprocess.call(r'C:\myfile.csv', shell=True)
should do it (not sure, andos.startfile
is cleaner). – Mcabeeshell=True
, forgot to include it in the question. Usingshell=True
would produce the error I mentioned above. – Condor