I have the following code:
with open(rawfile) as f, open(outfile,'w') as f2:
for x in f:
if (':') not in x and ('Station') not in x and('--')not in x and('hPa') not in x:
f2.write(x.strip()+'\n')
The "...if ___ not in x..." lines identify a line containing that string and removes the line while keeping the rest of the text in the same format. I would like to do this same thing, but remove any line containing a number greater than 10000.
You should be able to this by incorporating Regex (since what you have is a string). For that, you could do something like
import re
re.findall(r'\d{5,}', str)
This will identify numbers with 5 or more digits. Include this in some sort of if clause to remove the numbers you desire gone.
If you're wanting to identify the whole line including a 5 digit or more number, you can use
re.findall(r'^.+(\d{5,}).+$', str)