filter a file to a table

I have a file that contains the following lines of code. here the file displays a schedules which are sorted one by one .

at 12:00 the schedule of james version1 is :
first_task:eating:nothing
second_task:rest:onehour
third_task:watching:nothing 

at 12:00 the schedule of james version2 is :
first_task:eating:fruits
second_task:rest:twohour
third_task:watching:manga 

at 12:00 the schedule of alex version1 is :
first_task:eating:fruit
second_task:rest:halfhour
third_task:watching:horrorfilm 

at 12:00 the schedule of alex version2 is :
first_task:eating:meal
second_task:rest:nothing
third_task:watching:nothing 

at 18:00 the schedule of james version1 is :
first_task:eating:fastfood
second_task:rest:twohours
third_task:watching:series 

at 18:00 the schedule of james version2 is :
first_task:eating:nothing
second_task:rest:onehours
third_task:watching:series 

at 18:00 the schedule of alex version1 is :
first_task:eating:vegetals
second_task:rest:threehours
third_task:watching:manga 

at 18:00 the schedule of alex version2 is :
first_task:eating:bread
second_task:rest:fivehours
third_task:watching:manga 

at 22:00 the schedule of james version1 is :
first_task:eating:nothing
second_task:rest:sevenhours
third_task:watching:nothing

at 22:00 the schedule of james version2 is :
first_task:eating:meal
second_task:rest:sixnhours
third_task:watching:nothing

at 22:00 the schedule of alex version1 is :
first_task:eating:vegetals
second_task:rest:sevehours
third_task:watching:manga 

at 22:00 the schedule of alex version2 is :
first_task:eating:icecream
second_task:rest:sevenhours
third_task:watching:nothing 

Open in new window


I've tried to sort it this way :
12:00 eating:fruit
18:00 eating:vegetals
22:00 eating:nothing

12:00 rest:onhour 
18:00 rest:threehour
22:00 rest:sevenhour

12:00 watching:horrorfilm 
18:00 watching:manga
22:00 watching:nothing

Open in new window


using these commands :

awk -F '[\ :]' '/the schedule is/{h=$2;m=$3} /eating/{print " "h":"m" watching:"$3}' f.txt
awk -F '[\ :]' '/the schedule is/{h=$2;m=$3} /rest/{print " "h":"m" rest:"$3}' f.txt
awk -F '[\ :]' '/the schedule is/{h=$2;m=$3} /watching/{print " "h":"m" watching:"$3}' f.txt

Open in new window


Now I am looking to improve the filtered file by ignoring all non significant words and sorting the most valuable information in a table , I've tried to think/search how get this format but in vain .


James version1,12:00,18:00,22:00
eating,nothing,fastfood,nothing
rest,onehour,halfhour,sevenhours
watching,nothing,series,nothing

James version2,12:00,18:00,22:00
eating,fruits,nothing,meal
rest,twohour,onehours,sixnhours
watching,manga,series,nothing 

alex version1,12:00,18:00,22:00
eating,fruit,vegetals,vegetals
rest,halfhour,threehours,sevehours
watching,horrorfilm,manga,manga 

alex version2,12:00,18:00,22:00
eating,meal,bread,icecream
rest,nothing,fivehours,sevenhours
watching,nothing,manga,nothing

Open in new window

imad imadAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ozoCommented:
what are the non significant words, and what is the most valuable information?
0
imad imadAuthor Commented:
The non significant words are :

first_task
second_task:
third_task:
the schedule of

the most valuable for example : sorted as an csv table

James version1,12:00,18:00,22:00
eating,nothing,fastfood,nothing
rest,onehour,halfhour,sevenhours
watching,nothing,series,nothing
0
ozoCommented:
perl -00ne '
($t,$n)=/(\S+) the schedule of (.*) is :/;
push @{$s{$n}{""}},$t;
push @{$s{$n}{$1}},$2 while/task:(.*):(.*)/g;
END{
  for $n ( keys %s ){
      print $n,(map{join(",",$_,@{$s{$n}{$_}}),"\n"}sort keys %{$s{$n}}),"\n";
  }
}' f.txt;
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

imad imadAuthor Commented:
Thanks , but I am not good at perl ,

Any awk command ?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sarabandeCommented:
why "james version1" is one attribute and not two like "james", "version1"?
why eating,nothing is two (unrelated) attributes and not one like eating:nothing?
why did you turn relations like "James version2 12:00 eating:fruits" to be unrelated?

you could get two entities from the data:

entity 1: ID,Name,Version

1,james,1
2,james,2
3,alex,1
4,alex,2

Open in new window


entity 2: ID,Schedule,Task,Activity,What

1,12:00,1,eating,nothing
1,12:00,2,rest,onehour
1,12::00,3,watching,nothing
2,12:00,1,eating,fruits
2,12:00,2,rest,twohour
2,12::00,3,watching,manga
...

Open in new window



but I am not good at perl , Any awk command ?
i would write a little parser program with c++.

Sara
0
imad imadAuthor Commented:
it works
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.