Beispiel #1
0
 def read_from_dir(cls, path, outexcel=False, outpath=None):
     files = os.listdir(path)
     if outexcel:
         moutexcel = Excel(outpath)
         moutexcel.new().append([[item, item] for item in files], "sheet1")
         moutexcel.close()
     else:
         return files
            if re.match('^(-)?\d+((\.|.)\d+)?$',new_item) is not None:
                new_item = re.sub('.','.',new_item)
                new_row.append(float(new_item))
            else:
                all = False
                new_row.append(item)
        return new_row,all

if __name__ == '__main__':
    filename = r'E:\data\procedure\Process\reduction\data\admincode\2003.xls'
    acodefile = AdminCodeFile(filename)

    filename = r'E:\data\procedure\Process\reduction\data\2003_prefecture\3_3_按三次业人员就业状况_地级市_2003.xls'
    mexcel = WinExcel(filename)
    mdata = mexcel.read()
    reduction = CitydataReduction(mdata,acodefile)

    reduction.reduction()
    ndata = reduction.second_data
    print(reduction.second_data)

    outfile = r'd:\data\demo.xlsx'
    moutexcel = Excel(outfile)
    moutexcel.new().append(ndata, 'mysheet')
    moutexcel.close()





        else:
            y += coefs[0]*x1
        if coefs[2] in rules3:
            y += coefs[2]*np.log(x3)
        else:
            y += coefs[2]*x3

        pdata[''.join(['y',str(i+1)])] = y
    result.append(one_student_coefs)

    pdata.to_excel(excel_writer = ''.join([out_path,student,file_name]),index=False)

print(result)
out_path = 'E:\\temp\\lab\\result.xlsx'
mexcel = Excel(out_path)
mexcel.new().append(result)
mexcel.close()


'''
# 1. 正态分布的随机数
mu, sigma = 0, 1
s = np.random.normal(mu, sigma, 1000)
print(abs(mu - np.mean(s)) < 0.1, np.mean(s))

# 2. 生成数学表达式
x1 = np.random.randint(0,100,1000)
print(np.mean(x1))
y = 2 + 3*x1 + s
print(np.mean(y))
    # 输出相关信息
    print("-" * 30)
    if len(reduction.header) < 1:
        print("标题: ", "没有")
    else:
        print("标题: ", reduction.header[0])
    print("Number of Rows: ", len(reduction.second_data))
    for item in reduction.no_matched:
        print("Not Matched: ", item)
    for item in reduction.not_all_numeric:
        print("Not All Numeric: ", item)
    for item in reduction.no_matched_and_not_all_numeric:
        print("Not Matched and Not All Numeric: ", item)
    # for item in reduction.deleted_data:
    #    print('Deleted Row: ',item)
    for item in reduction.remark:
        print("Remark: ", item)
    for item in reduction.others:
        print("Others: ", item)
    print("*" * 30)

    moutexcel = Excel(target_file)
    moutexcel.new().append(ndata, "sheet")
    moutexcel.close()

    """
    moutexcel2 = Excel(delete_file)
    moutexcel2.new().append(reduction.deleted_data, 'sheet')
    moutexcel2.close()"""