Hi guys,
I have a huge data file that the first two columns are coordinates (latitude, longitude). I look for a way to extract the data window from the original file giving maximum and minimum values to the coordinates.
Here's an input example:
Here's the desire output:
I have a huge data file that the first two columns are coordinates (latitude, longitude). I look for a way to extract the data window from the original file giving maximum and minimum values to the coordinates.
Here's an input example:
Output:10.0 20.0 1 1
15.0 25.0 1 1
20.0 30.0 1 1
25.0 35.0 1 1
30.0 40.0 1 1
35.0 45.0 1 1
40.0 50.0 1 1
45.0 55.0 1 1
50.0 60.0 1 1
55.0 65.0 1 1
I want to write a file only with data which the latitude values (first column) are between 20.0 and 40.0, and the longitude values (second column) are between 30.0 and 50.0.Here's the desire output:
Output:20.0 30.0 1 1
25.0 35.0 1 1
30.0 40.0 1 1
35.0 45.0 1 1
40.0 50.0 1 1
Here's what I tried, but nothing is print on the exit file:#!/usr/bin/env python3 with open("entrada.txt","r") as fh, open("windowexit.txt","a") as sh: for row in fh: if float(row[0])>=20.0 and float(row[0])<=40.0 and float(row[1])>=30.0 and float(row[1])<=50.0: print(row, file = sh, end='')Thanks for the help. XD