I am a basic Python user and I have searched in multiple platforms how to delete from a large text file specific values but I haven't found anything similar to what I want to do . I have a large file (out.txt) and I want to remove all the 0 values and all values multiplied by 0 (75*0) in the large data file. After removing all those values I want to write it in a new text file (out2.txt). Suggestions please. Thanks!
I have tried this code;
content = open('out.txt', 'r').readlines()
content_set = set(content)
cleandata = open('clean.txt', 'w')
for line in content_set:
cleandata.remove(0)
I keep getting this error:
cleandata.remove(0)
AttributeError: '_io.TextIOWrapper' object has no attribute 'remove'
DATA FILE out.txt
75*0 78.8502 45.9301 13358*0 10.7678 0 23.9901 43.8503 77*0 1.3757 36.9888 15.0398 76*0 8.19519 0 4.11938 21.4933 23.832 76*0 34.7566
15.5595 21.0239 0 47.1607 76*0 14.9065 52.916 51.7825 13358*0 62.4689 22.8217 15.68 77*0 12.8943 0 32.1276 14.1273 76*0 39.6095
70.8503 72.8765 45.7607 76*0 12.5657 72.7567 58.0161 30.9 76*0 19.5879 648.696 111.501 13358*0 17.36 18.0555 85.0358 77*0 4.62265
55.7498 61.2049 76*0 762.354 8.34207 23.2367 16.0517 76*0 405.637 20.1265 8.17844 16.4698 76*0 107.228 35.1968 38.4117 13358*0