[ncl-talk] extracting lines in which a particular column matches a number say 1
Geeta Geeta
geetag54 at yahoo.com
Wed May 27 12:20:31 MDT 2020
Hi all.
I have a text file which has fixed length of 133 columns. I have to extract all the lines in which Column No 90 =1.
This data though is of fixed length but there are many spaces which are random. Kindly see the attached data. I was trying with str_fields_count and str_get_field functions but I am unable to get desired output.
one small part from the data file looks like
43295 1969 03 22 34.2 22.2 07 000.0 07.0 00 32 07.5 1 0 0 0 0 1 0 0 0 9 6 080 6 7 073
43295 1969 03 17 34.3 23.0 05 000.0 07.8 00 00 05.5 0 1 0 0 0 0 0 0 0 5 6 005
43295 1969 08 28 29.8 18.0 10 034.1 06.1 07 00 01.5 1 0 0 0 0 1 0 0 0 9 1 205 6 1 375 0 7 290
43295 1969 08 29 26.5 18.9 04 000.0 02.1 00 00 00.4 1 1 0 0 0 1 0 0 0 9 6 070 6 6 270 5 8 015 0 1 230
43295 1969 11 14 28.4 19.0 04 000.3 01.4 00 10 02.3 01 2 048 2 18 30 01 1 0 0 0 0 0 0 0 0 7 7 001 6 7 019
43295 1969 11 19 26.9 18.5 11 001.5 03.3 03 30 00.0 1 1 0 0 0 0 0 0 0 6 1 041 5 3 660
43295 1969 11 20 21.0 18.0 13 010.0 01.0 17 10 00.0 1 1 0 0 0 0 0 0 0 6 2 282 5 4 550
43295 1969 11 21 21.3 17.9 08 004.2 03.2 08 30 00.1 1 0 0 0 0 0 0 0 0 6 2 025
43295 1969 11 22 23.2 18.2 06 001.3 02.3 01 15 01.8 1 1 0 0 0 1 0 0 0 9 8 085 6 1 195 5 1 187
43295 1969 11 23 26.2 18.5 04 043.5 02.5 07 08 04.3 1 1 0 0 0 0 0 0 0 6 1 350 5 6 018 0 7 180
43295 1969 11 24 26.4 18.6 04 114.0 02.2 10 10 03.9 1 1 0 0 0 1 0 0 0 9 7 065 6 1 370 5 2 110 0 7 340
43295 1969 11 25 26.7 19.5 06 009.8 03.2 02 20 05.3 0 1 0 0 0 0 0 0 0 5 3 160 0 1 075
43295 1969 11 26 26.4 19.0 08 000.1 02.1 00 00 00.1 0 0 0 0 0 0 0 0 0
43295 1969 11 27 25.1 17.1 05 000.0 02.0 00 00 06.9 0 0 0 0 0 0 0 0 0
43295 1969 11 28 27.4 18.5 08 000.0 03.0 00 00 09.3 1 1 0 0 0 0 0 0 0 6 7 015 5 7 050 0 7 300
43295 1969 11 29 26.3 18.5 12 002.1 04.1 02 05 04.0 0 1 0 0 0 0 0 0 0 5 1 060 0 1 060
43295 1970 04 03 35.6 22.0 07 000.0 09.0 00 00 08.9 01 5 070 8 21 07 02 1 0 0 0 0 1 0 0 0 9 7 105 7 8 002 6 8 090 0 7 005
43295 1970 04 04 32.3 20.8 12 001.5 09.5 03 15 09.4 0 0 0 0 0 1 0 0 0 9 1 145 0 7 210
43295 1970 04 05 30.9 21.0 12 000.0 08.0 00 00 06.8 1 0 0 0 0 0 0 0 0 6 7 193
43295 1970 04 06 33.2 20.0 06 005.1 06.6 02 10 00.3 1 1 0 0 0 0 0 0 0 6 1 105 5 4 047
43295 1972 02 28 31.0 17.0 07 000.0 05.9 00 00 10.6 0 0 0 0 0 0 0 0 0
43295 1972 02 29 30.7 17.0 09 000.0 07.6 00 00 10.5 0 0 0 0 0 0 0 0 0
43295 1972 03 01 31.6 14.6 08 000.0 03.4 09.7 0 0 0 0 0 0 0 0 0
43295 1972 03 02 32.2 15.4 12 000.0 04.0 09.8 0 0 0 0 0 0 0 0 0
^
|
|
|
I have to extract all those lines in which field (AS SHOWN) is =1
Part of my code is shown below
nfields = str_fields_count(strs, delim) ; Count the fields separated
; by one or more spaces.
;print(nfields) ; nfields = 20
field = 25
subStrings = str_get_field(strs, field, delim)
print(subStrings)
year = str_get_cols(subStrings, 0, 3)
print(year)
Pls suggest
Geeta.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.dat
Type: application/octet-stream
Size: 3574 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20200527/95b38e23/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tsdates.v1.ncl
Type: application/octet-stream
Size: 1072 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20200527/95b38e23/attachment-0001.obj>
More information about the ncl-talk
mailing list