Hi ,
I have the following file which is basically a grid (has more than 100000 rows)
LLL1 PPP1
LLL1 PPP2
LLL1 PPP3
...............
LLL1 5500
.....
LLL2 PPP1
LLL2 PPP2
LLL2 PPP3
...............
LLL1 5500
.....
L100 PPP1
L100 PPP2
L100 PPP3
...............
2100 5500
..........
Using a mathematical formula I have to assign to each point a grid value. Let's say the formula is grid = int((PPP1+7)/8-int(PPP1/8). The input file will become:
Line Point Grid
LLL1 PPP1 1
LLL1 PPP2 1
LLL1 PPP3 2
...............
LLL1 5500 150
.....
LLL2 PPP1 1
LLL2 PPP2 1
LLL2 PPP3 2
...............
LLL2 5300 150
.....
L100 PPP1 1
L100 PPP2 1
L100 PPP3 2
...............
2100 5500 150
I need a summary of the unique values of the grid and some statistics as follows:
[CENTER]Grid #1
LLLL #
LLL1
LLL2
LLL3
....
L100
...
2100
FROM
PPPP
PPP1
PPP1
PPP1
...
PPP1
.....
PPP1
TO
PPPP
5550
5300
5100
...
5000
...
5500
Total
XXXX
XXXX
XXXX
...
XXXX
...
XXX[/CENTER]
[CENTER]Grid #2
LLLL #
LLL2
LLL3
....
L100
...
2100
FROM
PPPP
PPP1
PPP1
...
PPP1
.....
PPP1
TO
PPPP
5300
5100
...
5000
...
5500
Total
XXXX
XXXX
...
XXXX
...
XXX[/CENTER]
[CENTER]Grid #3
LLLL #
LLL1
LLL2
LLL3
....
L100
...
2100
FROM
PPPP
PPP1
PPP1
PPP1
...
PPP1
.....
PPP1
TO
PPPP
5550
5300
5100
...
5000
...
5500
Total
XXXX
XXXX
XXXX
...
XXXX
...
XXX[/CENTER]
Thanks in advance for any help.
PPP1, PPP2 is number or others in your read data?
I can't get 150 from 5500 with your formula : int(5500+7)/8-int(5500/8), so you need explain how you get 150 with 5500?
First of all thanks for you reply. In order to get the grid value we'll have to keep PPP1 in the second equation as absolute reference and to modify only first PPP1. If the PPP1 is 1001 than the formula will become int((5500+7)/8) - int(1100/8) = 563 (my mistake with 150). For another point let's say 2100 the grid values are (((2100+7)/8) - int(1100/8) = 138.
Hope this helps
Many Thanks
do you mean, the second var will always be 1100?
how from
LLL1 PPP1
LLL1 PPP2
LLL1 PPP3
to
LLL1 PPP1 1
LLL1 PPP2 1
LLL1 PPP3 2
Please put some read data, (replace ppp1, ppp2 with real number) and provide the expect output.
Hi,
Please find attached an excel file with a real example of the grid.
The PPPP var will not be always 1100, only in the 2nd part of the formula I need to keep the 1100 fixed as a reference for the grid.
Many thanks
I still don't understand the 1100 come from, but let we start it first.
Do you ask for something like this:
awk '{print $0, int(($1+7)/8)-int(1100/8)}' infile
5001 1001 489
5001 1002 489
5001 1003 489
5001 1004 489
5001 1005 489
5001 1006 489
5001 1007 489
5001 1008 489
5001 1009 489
5001 1010 489
or
awk '{print $0, int(($1+7)/8)-int($2/8)}' infile
5001 1001 501
5001 1002 501
5001 1003 501
5001 1004 501
5001 1005 501
5001 1006 501
5001 1007 501
5001 1008 500
5001 1009 500
Hello,
Please find bellow the formula that will give us the grid values:
$ awk '{print $0, int(($2+7)/8)-int(1100/8)}' grid.test | more
5001 1001 -11
5001 1002 -11
5001 1003 -11
5001 1004 -11
5001 1005 -11
5001 1006 -11
5001 1007 -11
5001 1008 -11
5001 1009 -10
5001 1010 -10
5001 1011 -10
5001 1012 -10
5001 1013 -10
5001 1014 -10
5001 1015 -10
5001 1016 -10
5001 1017 -9
5001 1018 -9
5001 1019 -9
5001 1020 -9
5001 1021 -9
5001 1022 -9
------------------------
5001 1076 -2
5001 1077 -2
5001 1078 -2
5001 1079 -2
5001 1080 -2
5001 1081 -1
5001 1082 -1
5001 1083 -1
5001 1084 -1
5001 1085 -1
5001 1086 -1
5001 1087 -1
5001 1088 -1
5001 1089 0
5001 1090 0
5001 1091 0
5001 1092 0
5001 1093 0
5001 1094 0
5001 1095 0
5001 1096 0
5001 1097 1
5001 1098 1
5001 1099 1
5001 1100 1
5001 1101 1
5001 1102 1
5001 1103 1
5001 1104 1
5001 1105 2
5001 1106 2
5001 1107 2
5001 1108 2
5001 1109 2
5001 1110 2
5001 1111 2
5001 1112 2
5001 1113 3
5001 1114 3
5001 1115 3
5001 1116 3
5001 1117 3
5001 1118 3
5001 1119 3
5001 1120 3
5001 1121 4
5001 1122 4
5001 1123 4
5001 1124 4
5001 1125 4
1100 will define the grid origin (if you'll put 1001 than 1001 will be the grid origin).
Thanks