Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with conversion

Status
Not open for further replies.

Fabrizio19

Technical User
Jan 23, 2012
3
NL
I want to use an awk script to convert a text file into a csv file.

The textstructure to be converted is as follow:

0.1740 1 18FF9E1Ex Rx d 8 00 40 FF FF FF FF FF FF
0.1740 2 187 Rx d 8 CD 76 00 00 00 00 00 00
0.1740 1 CF00400x Rx d 8 F6 7D 9C E1 22 FF FF 7D
0.1740 2 189 Rx d 8 52 02 00 00 00 00 00 00
0.1750 1 CF00300x Rx d 8 FF 0F 21 FF FF FF FF FF
0.1750 2 186 Rx d 8 FC 1D 00 00 00 00 00 00
0.1750 1 CFFCC27x Rx d 8 00 00 00 00 AF 77 5A 00
0.1750 2 188 Rx d 8 07 02 00 00 00 00 00 00
0.1760 2 381 Rx d 8 05 00 00 00 09 00 00 00
0.1760 1 C000003x Rx d 8 09 40 23 FF FF 1D FF FF
0.1760 2 202 Rx d 8 18 00 00 00 00 00 00 00

I want to filter lets say all lines with 187 and 381 and use the last 2 pair of numbers of the line and put them in a collumn.

I am using gawk for windows.
As i have no experience at all for this :) would really appreciate your help.

 
Hi

Please also post the sample output corresponding to the sample input and the sample processing condition you mentioned.


Feherke.
 
the input file input.txt has te following content

0.1740 1 18FF9E1Ex Rx d 8 00 40 FF FF FF FF FF FF
0.1740 2 187 Rx d 8 CD 76 00 00 00 00 00 00
0.1740 1 CF00400x Rx d 8 F6 7D 9C E1 22 FF FF 7D
0.1740 2 189 Rx d 8 52 02 00 00 00 00 00 00
0.1750 1 CF00300x Rx d 8 FF 0F 21 FF FF FF FF FF
0.1750 2 186 Rx d 8 FC 1D 00 00 00 00 00 00
0.1750 1 CFFCC27x Rx d 8 00 00 00 00 AF 77 5A 00
0.1750 2 188 Rx d 8 07 02 00 00 00 00 00 00
0.1760 2 381 Rx d 8 05 00 00 00 09 00 00 00
0.1760 1 C000003x Rx d 8 09 40 23 FF FF 1D FF FF
0.1760 2 202 Rx d 8 18 00 00 00 00 00 00 00

output.csv need to have the following content
Column1 Column2 Column3 Column4
Timestamp ID variablename1 variablename2
 
Sorry the output file needs to be different
We have ID 189 and we will use te last 2 pairs of the line
example 0.1740 2 189 Rx d 8 52 02 00 00 00 00 AA BB

the last 2 pairs have the meaning of speed. AABB if possible i need to convert the hex to integer.and put it into the column as follow

output.csv need to have the following content
Column1 Column2 Column3 Column4
Time Var1=speed var2= pressure var3=temp
0.1740 FFEE FFCD FFCD
0.1740 FFED FFCD FFCD
0.1740 FFCD FFCD FFCD
0.1750 FFED FFCD FFCD
0.1750 FFCD AFCD 0A04

 

No comprende...
Does not make sense yet, how do you get
from "00 00 AA BB" to "FFEE FFCD FFCD"?
[ponder]


----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top