0

I want to execute the following command:

ssconvert /data/sam.xls,/data/test.csv

I have tried:

 p = subprocess.Popen(["ssconvert", '/data/sam.xls','/data/test.csv'], stdout=subprocess.PIPE,shell=True)
   out = p.communicate()
   print"output", out

but it's not working.

How can I solve this issue?

pnuts
  • 58,317
  • 11
  • 87
  • 139
Abdul Razak
  • 2,654
  • 2
  • 18
  • 24

2 Answers2

1

This is worked

import subprocess
subprocess.call(["ssconvert","sample.xlsx","sample.csv"],cwd="pathtoyourfile") # pathtoyourfile must contain the xlsx and csv files
Abdul Razak
  • 2,654
  • 2
  • 18
  • 24
0

The correct command is not ssconvert /data/sam.xls,/data/test.csv. It should be: ssconvert /data/sam.xls /data/test.csv instead (note: the space, not comma between the input and output filenames).

If you use shell=True then you should pass the command as a string. There is no need to use shell=True in this case. If shell=False (default) then each command-line argument should be passed as a single list item:

#!/usr/bin/env python
import subprocess

subprocess.check_call(['ssconvert', '/data/sam.xls', '/data/test.csv'])

See Why subprocess.Popen doesn't work when args is sequence?

Community
  • 1
  • 1
jfs
  • 399,953
  • 195
  • 994
  • 1,670