如何从执行进程任务运行 py 文件? [英] How do I run a py file from execute process task?

查看:31
本文介绍了如何从执行进程任务运行 py 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 VS Community 2015 的 64 位窗口上.我正在尝试使用执行进程任务从 Visual Studio 运行 py 代码.尝试:

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 代码是:

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)

也尝试过,我尝试创建我的 py 文件的 exe 以便在执行进程任务中运行,但该 exe 也没有给出我想要的输出.我使用 pyinstaller 转换为 exe .

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.

提前谢谢

推荐答案

好的,这就是我出错的地方.我传递的参数在其值中有空格,因为 ssis 无法找到该值.所需要的只是在转义字符的帮助下在我的论点中添加双引号

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.

此外,退出代码 0 表示执行时没有错误,ssis 中的退出代码 2 表示路径不可用.

Also, exit code 0 means ther is no error while execution , exit code 2 in ssis means that path not available.

这篇关于如何从执行进程任务运行 py 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆