b3_trcd_EDCD_new
- # -*- coding:utf-8 -*-
- import re
- year="17A"
- ss='./data/'
- filename = ss+'EDCD%s.txt'%year
- '''
- 适应新版本
- '''
- p1 = r"^\s{4}(?:X|\W)\s{2}(C\d\d\d)\s.+\n"
- p2 = r"^(\d\d\d)\s{4}\d{4}\s{2}.+[CM]\s+(?:.*\.\.\d+|.*)\n"#C n3
- p3 = r"^\d\d\d\s{4}(\d{4})\s{2}.+[CM]\s+(?:.*\.\.\d+|.*)\n"
- p4 = r"^\d\d\d\s{4}\d{4}\s{2}.+([CM])\s+(?:.*\.\.\d+|.*)\n"
- p5 = r"^\d\d\d\s{4}\d{4}\s{2}.+[CM]\s+((?:.*\.\.\d+|.*))\n"
- p6 = r"^(\d\d\d)\s{4}\d{4}\s{2}.+[^\d]$\n"
- p7 = r"^\d\d\d\s{4}(\d{4})\s{2}.+[^\d]$\n"
- p8 = r"^\s{13}.+([CM])\s+(?:.*\.\.\d+|.*)\n"
- p9 = r"^\s{13}.+[CM]\s+((?:.*\.\.\d+|.*))\n"
- pattern1 = re.compile(p1)
- pattern2 = re.compile(p2)
- pattern3 = re.compile(p3)
- pattern4 = re.compile(p4)
- pattern5 = re.compile(p5)
- pattern6 = re.compile(p6)
- pattern7 = re.compile(p7)
- pattern8 = re.compile(p8)
- pattern9 = re.compile(p9)
- fr = open(filename)
- temp = "";
- flag = 0
- for line in fr.readlines():
- matcher1 = re.findall(pattern1,line)
- matcher2 = re.findall(pattern2,line)
- matcher3 = re.findall(pattern3,line)
- matcher4 = re.findall(pattern4,line)
- matcher5 = re.findall(pattern5,line)
- matcher6 = re.findall(pattern6,line)
- matcher7 = re.findall(pattern7,line)
- matcher8 = re.findall(pattern8,line)
- matcher9 = re.findall(pattern9,line)
- #print matcher
- w2 = open(ss+'b3_%s.csv'%year,'a')#a代表追加 w代表重写
- if matcher1:
- flag = 1
- for j in matcher1:
- temp = j
- if ((matcher2!=[])and(flag ==1 or 5 or 9)):
- flag = 2
- w2.write("\n"+temp+",")
- for j in matcher2:
- for k in j:
- w2.write(k)
- if ((matcher3!=[])and(flag ==2)):
- flag = 3
- w2.write(",")
- for j in matcher3:
- for k in j:
- w2.write(k)
- if ((matcher4!=[])and(flag ==3)):
- flag = 4
- w2.write(",")
- for j in matcher4:
- for k in j:
- w2.write(k)
- if ((matcher5!=[])and(flag ==4)):
- flag = 5
- w2.write(",")
- for j in matcher5:
- for k in j:
- w2.write(k)
- if ((matcher6!=[])and(flag ==1 or 5 or 9)):
- flag = 6
- w2.write("\n"+temp+",")
- for j in matcher6:
- for k in j:
- w2.write(k)
- if ((matcher7!=[])and(flag ==6)):
- flag = 7
- w2.write(",")
- for j in matcher7:
- for k in j:
- w2.write(k)
- if ((matcher8!=[])and(flag ==7)):
- flag = 8
- w2.write(",")
- for j in matcher8:
- for k in j:
- w2.write(k)
- if ((matcher9!=[])and(flag ==8)):
- flag = 9
- w2.write(",")
- for j in matcher9:
- for k in j:
- w2.write(k)
- w2.close( )
b3_trcd_EDCD_new的更多相关文章
随机推荐
- mysql之MMM高可用方案简介
MMM(Master-Master Replication Manager for MySQL) MySQL主主复制管理器,提供了MySQL主主复制配置的监控.故障转移和管理的一套可伸缩的脚本套件.在 ...
- GBDT 将子树结果当成lr输出
http://scikit-learn.org/stable/auto_examples/ensemble/plot_feature_transformation.html#example-ensem ...
- spring boot 配置 freemarker
1.springboot 中自带的页面渲染工具为thymeleaf 还有freemarker 这两种模板引擎 简单比较下两者不同, 1.1freemaker 优点 freemarker 不足:thym ...
- FP真验货客户的成品和半成品编码部分没有带尾续,导致FP规划错误 IN_SALES_ORDER数据不带CZ
错误描述:真验货客户的成品和半成品编码部分没有带尾续,导致FP规划错误 IT角度: IN_SALES_ORDER数据不带CZ 现时前台页面数据: 现时后台数据: 一.跟进情况 1.执行SAP_SALE ...
- <script language = "javascript">, <script type = "text/javascript">和<script language = "application/javascript">(转)
application/javascript是服务器端处理js文件的mime类型,text/javascript是浏览器处理js的mime类型,后者兼容性更好(虽然application/ ...
- POJ1950----DFS
Dessert Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 6193 Accepted: 2299 Descripti ...
- 第五章 二叉树(b)树的表示
- 在MyEclipse Tomcat可以运行但是在Tomcat 6.x上却不可以运行
- Python3 tuple 函数
Python3 tuple 函数 Python3 内置函数 描述 tuple 函数将列表转换为元组.. 语法 以下是 tuple 的语法: tuple( seq ) 参数 seq -- 要转换为元组 ...
- Eclipse中的SVN操作
--------------------siwuxie095 Eclipse 中的 SVN 操作 (一)发布项目 ...