我在一个文件中有660万行。每行的长度不同。我想使用R一次读取一行,根据某个字符串是否在该行中,我想将其写入文件或拒绝它。
发布于 2015-07-20 06:17:17
这应该是可行的:
f1 = open('fileYouWantToWriteTo.txt','w')
with open('fileToBeRead.txt') as f:
list(map(f1.write,filter(lambda x:'stringYouAreSearchingFor' in x, f)))
f1.close()
https://stackoverflow.com/questions/31509396
复制相似问题