zoukankan      html  css  js  c++  java
  • 数据解压

    # -*- coding: utf-8 -*-
    # ---------------------------------------------------------------------------
    # ErrorPointFinder.py
    # Created on: 2016-07-27 09:10:17.00000
    # (generated by ArcGIS/ModelBuilder)
    # Description:
    # ---------------------------------------------------------------------------

    import random
    from itertools import groupby
    import os
    import zipfile

    '''
    path = u"H:\基础数据及工作底图\非涉密成果\县级工作底图成果\第一批工作底图(16个县)"
    outpath = u"H:\基础数据及工作底图\非涉密成果\县级工作底图成果\output0"
    current_files = os.listdir(path)
    for file_name in current_files:

    print(file_name)
    dirname = path + "\" + file_name + "\DLG"
    if not os.path.exists(dirname):
    continue
    os.mkdir(outpath + "\" + file_name)
    filelist = []
    for root, dirlist, files in os.walk(dirname):
    for filename in files:
    filelist.append(os.path.join(root, filename))

    #Start to zip file ...
    fullzipfilename = outpath + "\"+ file_name + "\DLG.zip"
    destZip = zipfile.ZipFile(fullzipfilename, "w")
    for eachfile in filelist:
    destfile = eachfile[len(dirname):]
    print("Zip file %s..." % destfile)
    destZip.write(eachfile, destfile)
    destZip.close()

    #os.mkdir(outpath + "\" + file_name)
    '''


    path = u"E:\guangxi\output"
    current_files = os.listdir(path)
    for file_name in current_files:
    print(file_name)
    fullzipfilename = path + "\" + file_name + "\DLG.zip"
    fullunzipdirname = path + "\" + file_name
    srcZip = zipfile.ZipFile(fullzipfilename, "r")
    for eachfile in srcZip.namelist():
    print("Unzip file %s ..." % eachfile)
    eachfilename = os.path.normpath(os.path.join(fullunzipdirname, eachfile))
    '''
    eachdirname = os.path.dirname(eachfilename)
    if not os.path.exists(eachdirname):
    os.makedirs(eachdirname)
    '''
    fd=open(eachfilename, "wb")
    fd.write(srcZip.read(eachfile))
    fd.close()
    srcZip.close()


  • 相关阅读:
    集大软件工程15级结对编程week1
    集大软件工程15级个人作业Week2
    集大软件工程15级个人作业Week1
    Java 课程设计 "Give it up"小游戏(团队)
    Java 课程设计 "Give it up"小游戏设计(个人) 201521123077
    201521123077 《Java程序设计》第14周学习总结
    201521123077 《Java程序设计》第13周学习总结
    2019-助教总结
    软工的总分
    第四次团队作业
  • 原文地址:https://www.cnblogs.com/gispathfinder/p/5711771.html
Copyright © 2011-2022 走看看