本帖最后由 cfwyy77_bat 于 2019-8-19 10:26 编辑
关键就是对每列集合 生成笛卡尔积,感觉用python会比较方便的。写了个玩玩,仅供参考。- from itertools import product
- import os
-
- srcDir="E:/数据1"
- dstDir="E:/数据2"
-
- txtfiles=[f for f in os.listdir(srcDir) if f.endswith("txt") and os.path.isfile(f)]
-
- for txt in txtfiles:
- with open(txt,encoding="utf-8") as f:
- lines = [line.strip("\n").split("\t") for line in f]
- columns = [[i for i in colHasEmpty if i] for colHasEmpty in zip(*lines)]
- with open(os.path.join(dstDir,txt),"w",encoding="utf-8") as fw:
- for i in product(*columns):
- print("".join(i),file=fw)
复制代码
|