Hi, I'm new with awk and have some trouble with it. I have a file with geographic coordinates like this:
49.397506N,123.505509W,-2.63
49.397509N,123.505495W,-2.58
49.397503N,123.505481W,-2.54
49.397505N,123.505468W,-2.50
49.397504N,123.505454W,-2.48
49.397502N,123.505440W,-2.44
The three columns (separated by commas) represent Y, X and Z values. I want it to be X, Y and Z, to remove the letters, and to make the X negative and the Z positive.
I run this code in cmd:
awk –F[,NW] -v OFS=, {print-$3,$1,-$5} originalfile.txt > newfile.txt
The new file is like this:
-123.506,49.397506,2.63
-123.505,49.397509,2.58
-123.505,49.397503,2.54
-123.505,49.397505,2.5
-123.505,49.397504,2.48
-123.505,49.397502,2.44
It is perfect except that it removes three digits from my X.
I tried many different codes and searched on forums, but I could not find anything to help me.
I hope you will help me! Thanks a lot!
49.397506N,123.505509W,-2.63
49.397509N,123.505495W,-2.58
49.397503N,123.505481W,-2.54
49.397505N,123.505468W,-2.50
49.397504N,123.505454W,-2.48
49.397502N,123.505440W,-2.44
The three columns (separated by commas) represent Y, X and Z values. I want it to be X, Y and Z, to remove the letters, and to make the X negative and the Z positive.
I run this code in cmd:
awk –F[,NW] -v OFS=, {print-$3,$1,-$5} originalfile.txt > newfile.txt
The new file is like this:
-123.506,49.397506,2.63
-123.505,49.397509,2.58
-123.505,49.397503,2.54
-123.505,49.397505,2.5
-123.505,49.397504,2.48
-123.505,49.397502,2.44
It is perfect except that it removes three digits from my X.
I tried many different codes and searched on forums, but I could not find anything to help me.
I hope you will help me! Thanks a lot!