| | |
| | | fdatas = [] |
| | | with open(f"{base_path}/Transaction.csv", 'r', encoding='utf-8') as file: |
| | | csv_reader = csv.reader(file) |
| | | total_lines = csv_reader.line_num |
| | | print("总行数:", total_lines) |
| | | # 获取表头:: [ExchangeID,SecurityID,TradeTime,TradePrice,TradeVolume,ExecType,MainSeq,SubSeq,BuyNo,SellNo,Info1,Info2,Info3,TradeBSFlag,BizIndex,LocalTimeStamp] |
| | | headers = next(csv_reader) |
| | | print("表头:", headers) |
| | | # 遍历数据行 |
| | | _path = f"{base_path}/Transaction_filter.csv" |
| | | percent = 0 |
| | | with open(_path, 'w', newline='', encoding='utf-8') as csvfile: |
| | | # 创建一个 CSV 写入器对象 |
| | | writer = csv.writer(csvfile) |
| | | # 逐行写入数据 |
| | | count = 0 |
| | | for row in csv_reader: |
| | | count += 1 |
| | | p = count * 100 // total_lines |
| | | if p != percent: |
| | | percent = p |
| | | print(f"**进度:{percent}%") |
| | | if row[1] not in target_codes and not parse_all: |
| | | continue |
| | | # 将文件写入到文本 |