Reputation: 55
I am on a 64 bit windows with VS Community 2015. I am trying to run py code from Visual Studio using execute process task.
Tried:
But, it does not give me any output.
Py code is:
import patoolib
import glob
import os
import csv
zipSrc="C:\\Users\\Suraj\\Documents\\Pyhton\\Python scripts\\Input.zip"
zipDst="C:\\Users\\Suraj\\Documents\\Pyhton\\Python scripts\\Zip Output"
formatSrc="C:\\Users\\Suraj\\Documents\\Pyhton\\Python scripts\\Output Format.csv"
finalOutput="C:\\Users\\Suraj\\Documents\\Pyhton\\Python scripts\\Output"
colValues=[]
widthValues=[]
sepValues=[]
widthSum=0
with open(formatSrc,'r') as forMat:
forMatReader = csv.reader(forMat)
for line in forMatReader:
colValues.append(line[1])
widthValues.append(line[0])
for i in widthValues:
widthSum += int(i)
sepValues.append(widthSum)
patoolib.extract_archive(zipSrc,outdir=zipDst)
os.chdir(zipDst)
fileList=glob.glob("*.csv")
for file in fileList:
with open(file,'r') as f, open(finalOutput+"\\"+file,'w',newline='') as f2:
fileReader = f.readlines()
writeData = csv.writer(f2)
writeData.writerow(colValues)
for line in fileReader:
start=0
temp=[]
for value in sepValues:
temp.append(line[start:value])
start = value
writeData.writerow(temp)
Also tried, I tried creating exe of my py file so as to run in execute process task but that exe also does not give my desired output. I used pyinstaller for converting to exe .
Any kind of suggestions would be appreciated.
Thnx in advance
Upvotes: 1
Views: 7562
Reputation: 55
Ok, so here is where I was going wrong. The argument which I was passing had spaces in its value because of ssis was having trouble to find the value. All that was needed was to add double quotes in my argument with the help of escape character
This is how you need to pass I passed arguments which gave me desired output.
Also, exit code 0 means ther is no error while execution , exit code 2 in ssis means that path not available.
Upvotes: 1
Reputation: 2402
The target machine where the Python is running firstly needs to have the python.exe in there somewhere. Once you confirm this, you need to call the python.exe from the execute process task and pass the .py file as a parameter in there. This will execute your python code without issues.
Thanks,
RV
Upvotes: 1