Importing Data into Dat Array
Kurt Finnie
Posts: 21
I would like to create an array of words, 11 per row with 99 rows, all initially assigned a zero value, such as...
DAT
C1 word 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
C2 word 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
... C99
Symbolically, the C(n) stands for Competitor(n), the first array element is a unique number that identifies the competitor and the second array element identifies the XBee transceiver serial number associated with that competitor. The remaining array elements per row will be filled in with numbers representing the finish time per (up to 9) races.
I would then create an external dat file comprised of two words per row, with as many as 99 rows, such as...
1234, 5678
2345, 6789
3456, 7890
etc, these being the unique number identifying the competitor and the XBee transceiver serial number.
I then want to write the contents of the external dat file into the program so that the values in the DAT array become:
C1 1234, 5678, 0, 0, 0, 0, 0, 0, 0, 0, 0
C2 2345, 6789, 0, 0, 0, 0, 0, 0, 0, 0, 0
C3 3456, 7890, 0, 0, 0, 0, 0, 0, 0, 0, 0
etc
Subsequently, I will do a lookup on the competitor identification and the race number, and assign the finish time to the appropriate array element.
Anyone able to help me figure this out?
Kurt
DAT
C1 word 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
C2 word 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
... C99
Symbolically, the C(n) stands for Competitor(n), the first array element is a unique number that identifies the competitor and the second array element identifies the XBee transceiver serial number associated with that competitor. The remaining array elements per row will be filled in with numbers representing the finish time per (up to 9) races.
I would then create an external dat file comprised of two words per row, with as many as 99 rows, such as...
1234, 5678
2345, 6789
3456, 7890
etc, these being the unique number identifying the competitor and the XBee transceiver serial number.
I then want to write the contents of the external dat file into the program so that the values in the DAT array become:
C1 1234, 5678, 0, 0, 0, 0, 0, 0, 0, 0, 0
C2 2345, 6789, 0, 0, 0, 0, 0, 0, 0, 0, 0
C3 3456, 7890, 0, 0, 0, 0, 0, 0, 0, 0, 0
etc
Subsequently, I will do a lookup on the competitor identification and the race number, and assign the finish time to the appropriate array element.
Anyone able to help me figure this out?
Kurt
Comments
BEGIN {i = 1}
{printf("C%d %d,%d,0, 0, 0, 0, 0, 0, 0, 0, 0\n", i, $1, $2)
i++}
with the following input file
1234, 5678
2345, 6789
3456, 7890
produces the following output
C1 1234,5678,0, 0, 0, 0, 0, 0, 0, 0, 0
C2 2345,6789,0, 0, 0, 0, 0, 0, 0, 0, 0
C3 3456,7890,0, 0, 0, 0, 0, 0, 0, 0, 0
It could probably also be done in Emacs or vi or other programming editors.
John Abshier
At the end of the day, the now filled data array is then copied back to flash drive as a dat file and then downloaded to Excel for calculation of handicaps and printing out of the day's results.
John, I don't see that printf is available.