本帖最后由 wanghan519 于 2024-1-5 15:49 编辑
py写的,不严谨,请小心测试,另外,json本身是啥样的,有可能简单一点- ret = []
- with open('a.csv', 'r') as f:
- for i in f:
- arr = i.strip().split('\t')
- a = arr[0]
- b = []
- for j in arr[1:]:
- try:
- float(j)
- b.append(j)
- except:
- if b:
- ret.append(b)
- if len(b) == 6:
- for k in ret:
- k.append(b[-1])
- b = [a, j]
- ret.append(b)
- for k in ret:
- k.append(b[-1])
- print('\n'.join(map(lambda x:'\t'.join(x[:6]), ret)))
复制代码
|