zoukankan      html  css  js  c++  java
  • python小脚本(18-11.10)-修改excle后批量生成,作用:导入数据时,系统做了不能导入重复数据时的限制时使用 -本人是小白,大神勿扰

    from testcase.test_mokuai.operation_excle import OperationExcle
    import shutil

    class test_daoru():
    #一个小脚本,修改excle文件后另存为,用于导单(导单时会读取excle文件内容,判断当前导入的数据是不是已导入)
    def test_a(self):
    col_num=7
    num=2
    file = r'F:excle_test est1.xls'
    new_name = r'F:excle_test'
    while num<21:
    new_path = new_name + r' est' + str(num) + '.xls'
    shutil.copy(file, new_path) #在使用file前复制该文件,使用后在复制会导致复制的内容与file完全一致且复制只会生效一次
    self.ope = OperationExcle(file, 0) #复制时,需将操作的目标文件写在循环内,如果写在循环外,会导致对象内存地址是一个,导致复制的excle与源文件数据一致,无法达到预期效果
    row_count = self.ope.get_lines()
    num+=1
    for i in range(1,row_count):
    data_num=int(self.ope.get_cell_value(i,col_num))
    new_data_num=data_num+1
    new_file=self.ope.write_value(i,col_num,new_data_num)


    if __name__ =="__main__":
    te_d=test_daoru()
    te_d.test_a()
    脑子不够用当然只能脚踏实地的做事情!
  • 相关阅读:
    Python并发编程之多进程(实战)
    ThreadPoolExecutor源码分析
    JDK 1.8 JVM的变化
    JDK1.8 hashMap源码分析
    Spring解决循环依赖
    spring
    实现一个可重入锁和不可重入锁
    B树与B+树
    WebMagic
    Java高频面试题
  • 原文地址:https://www.cnblogs.com/qtclm/p/9939996.html
Copyright © 2011-2022 走看看