1

Python2.7を使用して小さなスクリプトを作成しました。

py2exeを使用して、このチュートリアルを使用して実行可能ファイルを作成しようとしています。

私はというexeファイルを作成することができますsdf.exe

sdf.exeのあるディレクトリに必要なすべてのライブラリがあります。

sdf.exeを実行すると、コマンドラインからエラーやメッセージが表示されません。ただし、プログラムは、と呼ばれるファイルを作成するという意図された処理を実行しませんoutput.csv

私が実行するsdf.pyと、問題なく動作します。ただし、実行しても何も実行さsdf.exeれず、エラーは返されません。

私は何が欠けていますか?どうもありがとうございます!

完全なコードは次のとおりです。

import csv


thefile = []
output = []


def dowork():
    global thefile
    sourceFile='e.csv'
    thefile=ReadFile(sourceFile)
    CleanFile(sourceFile)    
    ProcessFile()
    AddHeader()
    WriteFile()

def ReadFile(filename):
    return list(csv.reader(open(filename, 'rb'), delimiter=',', quotechar='"'))[1:]

def CleanFile(sourceFile):
    global thefile
    iBalance=8
    iAging=7
    thefiletmp=[]
    for i, line in enumerate(thefile):
        if line[2]=='':
            del thefile[i]
        else:
            if thefile[i][iAging]=='':
                thefile[i][iAging]='0'
            thefiletmp.append(line[4:])
    thefile=thefiletmp


def ProcessFile():
    global thefile
    iCompany=1
    iNum=0
    iDate=2
    iAging=3
    iBalance=4
    COMPANIES=GetDistinctValues(1)
    mytemparray=[]
    mytempfile=[]
    TotalEachCustomer=0
    for company in COMPANIES:
        for line in thefile:
            if line[iCompany]==company:
                mytemparray.append(line[iCompany])
                mytemparray.append(line[iNum])
                mytemparray.append(line[iDate])
                iAgingCell=int(line[iAging])
                line[iBalance]=line[iBalance].replace(',','')
                if iAgingCell in range(0,31):
                    mytemparray.append(line[iBalance])
                    mytemparray.append('0')
                    mytemparray.append('0')
                    mytemparray.append('0')
                if iAgingCell  in range(31,61):
                    mytemparray.append('0')
                    mytemparray.append(line[iBalance])
                    mytemparray.append('0')
                    mytemparray.append('0')
                if iAgingCell  in range(61,91):
                    mytemparray.append('0')
                    mytemparray.append('0')
                    mytemparray.append(line[iBalance])
                    mytemparray.append('0')
                if iAgingCell >90:
                    mytemparray.append('0')
                    mytemparray.append('0')
                    mytemparray.append('0')
                    mytemparray.append(line[iBalance])
                TotalEachCustomer+=float(line[iBalance])
                mytemparray.append(line[iBalance])
                mytempfile.append(mytemparray)
                mytemparray=[]
        mytempfile.append(['','','','','','','',''])
        mytempfile.append([company+ " Total",'','','','','','',TotalEachCustomer])
        mytempfile.append(['','','','','','','',''])
        TotalEachCustomer=0
    thefile=mytempfile

def AddHeader():
    global thefile
    thefile[:0]=[['Account Name', 'Num','Date', '0-30', '31-60', '61-90', '91 Plus','Total']]

def WriteFile():
    global thefile
    out_file = open("output.csv", "wb")
    writer = csv.writer(out_file)
    for line in thefile:
        writer.writerow(line)
    out_file.close()


def GetDistinctValues(theColumn):
    return sorted(list(set(line[theColumn] for line in thefile)))
4

1 に答える 1

3

私はそれがコンパイルされていないバージョンからまったく動作することに驚いています。dowork()どこが呼ばれているのかわかりません。

私はあなたがただdowork()sciptの底に追加する必要があると思います

于 2012-09-27T21:56:40.563 に答える