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()


  • 相关阅读:
    Easy Code 自定义的模板
    LINUX批量修改文件名
    解决FTP登录太慢
    linux 命令
    Linux rename命令
    MySQL字段重复出现多少次
    kafka安装
    Redis 5.0简单安装
    Tomcat常用配置
    jenkins安装和简单配置
  • 原文地址:https://www.cnblogs.com/gispathfinder/p/5711771.html
Copyright © 2011-2022 走看看