The data set I have is an ASCII file containing a header over 4 lines and the actual data comprised of dezimal numbers in a 1000x1000 grid (1000 lines and 1000 columns).
Since I want to plot the data in GMT I need to convert it into the following format:
[x coordinate] [y coordinate] [value]
This means every single value will be in a single line preceeded by its coordinates. For simplicity lets say the upper left corner has coordinats 0,0 and the grid spacing is 500 in both directions.
I tried the following using "awk"
Since I'm posting my problem here it is obvious the the code above is not working. Can anybody tell why it is not working or a better solution?
You are running a loop from 1 to 1000 over columns which don't exist and lines haven't been read. BEGIN takes place before any data is read.
Further, awk does not process expressions inside strings.
That you have a loop from 1 to 1000 doesn't tell awk to read 1000 lines anyway. awk has its own built in loop, which it will use if you don't specifically force it not to (by using BEGIN or END).
It is always beneficial to post sample input and output data, describe the underlying structure, show the (intended!) logics or algorithms that connect the two, and - in case of failures - what and where fails, and error messages.
In your case - which are the coordinates, and which are the values to plot? Is it [row No.] [col No.] field value? When looping across the fields, does it make sense to use $(i-1) and $i, and then only increment by 1 (which would mean you're using $i twice)?
Hi All,
We are trying to replace a 3rdparty where we don't know how they handled the reader part here. The query below is getting 197 * 2038017 row in the table.
In the below code we are trying to run the query and execute in the DB part and fetch and read the record. That is where it is... (1 Reply)
Hello Everyone,
I have a input file looks like
-0.005-0.004-0.003-0.002-0.00100.0010.0020.0030.0040.005My desired output should look like
-0.005
-0.004
-0.003
-0.002
-0.001
0
0.001
0.002
0.003
0.004
0.005I had some success in getting the desired output. But i face a problem when i... (15 Replies)
Input file
2 1159,310,
4 142,199,218,91,
3 91,273,349,
Desired output result
2 1469
4 650
3 713
I have long list of input file as shown above.
It has a "," delimited to separate between each record in column 2.... (1 Reply)
Hi All,
Iam trying to set the value to the array... Still its not happening
Following is the code:
#!/usr/bin/ksh
filenames="x";
filenames="y";
echo $filenames;
echo $filenames;
O/P:
x
x
Iam expecting (2 Replies)