regex - python regular expressions match # ner -
I'm trying to remove posts using regular expressions in a file like this:
36 17.8 9 n, 2 51.62 w35 51.13 n, 2 51.62 w35 51.13 n, 2 49.14 w 36 17.8 9n, 2 49.14 w 36 17.8 9n, 2 46.66 w35 51.13n, 2 46.66w35 51.13 n, 2 44.18 w 36 17.8 9n, 2 44.18 w 36 17.8 9n, 2 41.7w35 51.13n, 2 41.7w35 51.13n, 2 39.22w 36, 17.8 9n, 2 39.22w 36, 17.8 9n, 2 36.74W 35 51.13 N, 2 36.74W35 51.13A 2 34.26 W 36 17.8 9 N 2 34.26 W. This is a .txt file.
To extract the data, regex is: pattern = r '((? M) ^ \ t \s ([1-9]? [0- 9] ) \ S ([0- 9]? [0- 9] \. [0-9] {0,2})) \ s ([ns]), \ r {0} ([1-9] ]? [0-9]) \ s ([0-9]? [0-9] \ [0- 9] {0,2}). ([WE]) ' I can remove the groups to process the stars to float but I want to know
For example (3, 35.8521, -2.685666) How can I store a ID in a list as a 'ID' for each ID in a row? > In a list, a tube or some iterative
I will use the partition instead of regex:
open ('coordinates.txt', 'r') as file: for file in line: coord = [pair.split ()) for line in line.split (', ']]
Comments
Post a Comment