Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

Removing a number from a string

$
0
0

There is a file with a list of numbers.Example:

**AK  v       0.00o      0.00       0.00       0.00       0.00       0.00       0.00        750.00       0.00       0.00       0.00       0.00       0.00       0.00        750.00      43.00       0.00       0.00       0.00       0.00       0.00        585.00      43.00      -7.00       0.00       0.00       0.00       0.00   -16611181.71     -90.16t     -7.00       0.00       0.00       0.00       0.00        585.00      57.00       0.00       0.00       0.00       0.00       0.00        750.00      57.00       0.00       0.00       0.00       0.00       0.00        750.00     100.00       0.00       0.00       0.00       0.00       0.00          0.00     100.00       0.00       0.00       0.00       0.00       0.00          0.00      56.99       0.00       0.00       0.00       0.00       0.00        165.00      56.99      -7.00       0.00       0.00       0.00       0.00   16612362.17     344.30t     -7.00       0.00       0.00       0.00       0.00        165.00      42.99       0.00       0.00       0.00       0.00       0.00          0.00      42.99       0.00       0.00       0.00       0.00       0.00          0.00       0.00       0.00       0.00       0.00       0.00       0.00**

You need to remove the entire line from it, where the number > 12000 or the number < -12000.I tried to split the string into substrings and compare the value, but nothing worked :(

for line in infile:    if line.startswith(''):        str = line.split()        numbers = int(str[0])    if not (numbers < 12000) or not (numbers > -12000):        outfile.write(line)

Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>