using awk for volatile column list

Hi guys

I have my 5th column like this

12
12:00
12:13:14
5-12:13:14

Meaning

5 days 12 hrs 13 minutes and 14 seconds

I need to split this column into above meaning format. But all other columns are separated by single while space.

I am using awk command to print other columns. please help me here!

% yorker

i don't follow what needs to 'split'. give a sample input and a desired output using the VBcodes

The 5th column value "5-12:13:14" should be converted into "5 days 12 hrs 13 minutes and 14 seconds" and stored into table in the database.. This value will be like 13:14 meaning that 13 hours and 14 seconds, read from right to left, I think you can follow this now..pls let me know if you still want more accurate. But this column

'what is a 'column'?
how are your records separated?
Is this '5-12:13:14' is only valid format of what needs to be 'split' and reformated or is e.g.'12' also valid (meaning '12 seconds')?
a couple of sample records/lines with varying values would be helpful (obviously).

pls use VB codes when giving samples.

given yorker.txt

12
12:00
12:13:14
5-12:13:14 

and yorker.awk

BEGIN {
  FS="[:-]"

  timeN=split("seconds minutes hrs days", timeA, " ")
}
{
   for(i=1; i<=NF; i++)
     printf("%s%s %s", (i==1)?"":" ", $i, timeA[NF-i+1])
   print ""
}

nawk -f yorker.awk yorker.txt
produces:

12 seconds
12 minutes 00 seconds
12 hrs 13 minutes 14 seconds
5 days 12 hrs 13 minutes 14  seconds

Sample records
---------------
# Name Time
1 Elvis 12
2 Victor 12:00
3 Yorker 12:13:14
4 Prince 5-12:13:14

The columns are separated by white space..but if you look at the 'time' column, the format is not very standard..it can be seconds alone, or combination of minutes and seconds, or combination of hours, minutes,and seconds. But days if there is "-" (hyphen), it means time is more than 24 hours and they converted it into days.

Eg.

5-12:13:14

Meaning

5 days 12 hrs 13 minutes and 14 seconds

got me?

look at my previous post.
it looks like you have THREE columns - not 5 you stated originally.
given your sample input file, what would the expected output be?

Thank you , I appreciate your time for me, I think this will work out for me, but need to test this against table.

given yorker.txt:

# Name Time
1 Elvis 12
2 Victor 12:00
3 Yorker 12:13:14
4 Prince 5-12:13:14

and yorker.awk:

BEGIN {
  SEPtime="[:-]"

  FLDtime="3"

  timeN=split("seconds minutes hrs days", timeA, " ")
}
/^#.*/ { print; next }

{
   _tmpN=split($FLDtime, _tmpA, SEPtime)

   timeS=""
   for(i=1; i<=_tmpN; i++)
     timeS = timeS sprintf("%s%s %s", (i==1)?"":" ", _tmpA, timeA[_tmpN-i+1])
   $3= "'" timeS "'"
   print
}

nawk -f yorker.awk yorker.txt
produces:

# Name Time
1 Elvis '12 seconds'
2 Victor '12 minutes 00 seconds'
3 Yorker '12 hrs 13 minutes 14 seconds'
4 Prince '5 days 12 hrs 13 minutes 14 seconds'