Gents,
Using the following code i am able to output the information i need, but some of the strings are not complete due to the separator : used..
Kindly can u help me to get all string after the first :
Example in the output file column 16 i should get
17/11/25 03:43:51:732000 [13431732000 microsec]
but i got
732000[13431732000microsec]
And also i don't understand why i dont get information for last records
Here the code
awk 'BEGIN {
qq="\""
tab=sprintf("\t")
FS=":"
OFS=","
fldL="SL,SN,SI,StackNb,FleetNb,DsdNb,SweepCounter,SweepType,SweepStatus,Drive,GpsStatus,GNGSA,GNGST,GPZDA,PTNL,TB,QCtype,TimeInhibit,timeendofprevsweeptoup,padup,paddown,timeuptodown,timedowntopressureswitchON,timedowntoready,timedowntosweep,sweeplength"
fldN=split(fldL, fldT, OFS)
for(i=1; i in fldT; i++)
fldA[fldT]=i
print fldL
}
function normStr(str)
{
gsub("[" OFS qq tab " ]", "", str)
return str
}
function arrayFull(a, i)
{
for(i=1; i<= fldN; i++)
if (!(i in a))
return 0
return 1
}
arrayFull(outputA) {
for(i=1; i in outputA; i++)
printf("%s%s", outputA, (i==fldN)?ORS:OFS)
split("", outputA)
}
normStr($1) in fldA {
fld1=normStr($1)
fld2=normStr($NF)
if (normStr($2) == "[") {
getline fld2
fld2=normStr(fld2)
}
outputA[fldA[fld1]]=fld2
}' file1.txt > test.csv
Attached the input file and output file i got
Appreciate your help