我想将两个空列表之间的所有列表转换为一个列表。例子
[]
['The','tablets','are','filled','into','cylindrically','shaped','bottles','made','of','white','coloured']
['polyethylene.','The','volumes','the','depend','on','tablet','strength','and','amount','of']
['tablets,','ranging','from','20','to','175','ml.','screw','type','cap','is','coloured']
['polypropylene','equipped','with','a','tamper','proof','ring.']
[]
['PVC/PVDC','blister','pack']
[]
['Blisters','in','thermo-forming','process','PVC/PVDC','base','web.','Each','tablet']
['is','separate','lidding','foil','aluminium','welded','on.','blisters']
['are','opened','by','pressing','through','foil.','PVDC','contact','with']
['the','tablets.']
[]
['Aluminium','pack']
[]
从这开始,我想要的第一个列表是:
['The','coloured','polyethylene.','tablets,'polypropylene','ring.']
下一个列表变为:
['PVC/PVDC','pack']
,该模式应继续。 到目前为止的代码:
import csv,re
filepath = r'C:\Users\techj\Music\Data\Tagged\090388 (1.0,CURRENT,LATEST APPROVED.txt)'
with open(filepath) as f:
content = f.readlines()
# s = ' '.join(x for x in content if x)
# print(s)
for line in content:
line = line.split()
print(line)