Hello world of python programming .
I am trying and struggling to parse a series messages from text file that has different unique patterns and save them as txt files using python programming.
I have as input txt file:
this is the type formats of all rows that txt have , so each row is repeated on given txt file and it has its own unique pattern as I showed above, where the key words [INFO] , [PERFECT] are not changed per the message those key words values are not changed in this message pattern.
consider each row is a new message , so at each row there is a new message starts irrelative to the other messages.
what Im trying to implement in python a function that reads line by line the given txt file to a function as input and all rows there has different patterns of messages as I mentioned above and to dump all rows / messages that has the certain type of keyword [PERFECT] :
to another txt file. so then if I go to another txt file I shall see all rows there has this type of messages:
Now after sniffing this type of message that has keyword [PERFECT] from the given txt(input txt) , I need to read line by line the new txt file that I generated that has the certain message type and then take the load index values and dump them in another txt file that has just the values of load index.
Function description:
Given txt file to the function as input that txt file has all messages patterns that I mentioned above and at each row there is new message:
Results/output of the function:
1. Generating txt file that has all rows of the **certain pattern** that I explained above (all rows that has word **[PERFECT]** so the generated txt file shall be having all messages / rows that has **[PERFECT]** :
2. Then generating a another new txt file for the load index values which in my case load index values found inside [ ] of the word load index ( load index [value] ), so the function shall dump in new txt file the values of the load index **as column** into the another new generated txt file :
1
1
1
How to parse and implement in python that function functionality?
thanks alot for any cooperation !
I am trying and struggling to parse a series messages from text file that has different unique patterns and save them as txt files using python programming.
I have as input txt file:
Code:
[#11:23][INFO][0x0015a] it's here and it's optimally required start index[1] , length[15]
INFO isn't NULL
[#12:25][PERFECT][0x0015a] process returned as NULL load index[1] , length[20] , type[0]
[#13:3][INFO][0x0015a] it's here and it's optimally required start index[1] , length[15]
PERFECT isn't NULL
[#4:23][INFO][0x0015a] it's here and it's optimally required start index[1] , length[15]
Time is here [Tick:135055] , Time: 17, index: 608, CastedType:20002, area :0
[#15:23][INFO][0x0015a] it's here and it's optimally required start index[1] , length[15]
[#16:25][PERFECT][0x0015a] process returned as NULL load index[1] , length[20] , type[0]
[#17:3][INFO][0x0015a] it's here and it's optimally required start index[1] , length[15]
[#8:23][INFO][0x0015a] it's here and it's optimally required start index[1] , length[15]
time is here [Tick:135055] , Time: 17, index: 608, CastedType:20002, area :0
[#16:23][INFO][0x0015a] it's here and it's optimally required start index[1] , length[15]
[#14:25][PERFECT][0x0015a] process returned as NULL load index[1] , length[20] , type[0]
[#18:3][INFO][0x0015a] it's here and it's optimally required start index[1] , length[15]
[#6:23][INFO][0x0015a] it's here and it's optimally required start index[1] , length[15]
Time is here [Tick:135055] , Time: 17, index: 608, CastedType:20002, area :0
this is the type formats of all rows that txt have , so each row is repeated on given txt file and it has its own unique pattern as I showed above, where the key words [INFO] , [PERFECT] are not changed per the message those key words values are not changed in this message pattern.
consider each row is a new message , so at each row there is a new message starts irrelative to the other messages.
what Im trying to implement in python a function that reads line by line the given txt file to a function as input and all rows there has different patterns of messages as I mentioned above and to dump all rows / messages that has the certain type of keyword [PERFECT] :
Code:
[#12:25][PERFECT][0x0015a] process returned as NULL load index[1] , length[20] , type[0]
to another txt file. so then if I go to another txt file I shall see all rows there has this type of messages:
Code:
[#12:25][PERFECT][0x0015a] process returned as NULL load index[1] , length[20] , type[0]
Now after sniffing this type of message that has keyword [PERFECT] from the given txt(input txt) , I need to read line by line the new txt file that I generated that has the certain message type and then take the load index values and dump them in another txt file that has just the values of load index.
Function description:
Given txt file to the function as input that txt file has all messages patterns that I mentioned above and at each row there is new message:
Code:
[#11:23][INFO][0x0015a] it's here and it's optimally required start index[1] , length[15]
INFO isn't NULL
[#12:25][PERFECT][0x0015a] process returned as NULL load index[1] , length[20] , type[0]
[#13:3][INFO][0x0015a] it's here and it's optimally required start index[1] , length[15]
PERFECT isn't NULL
[#4:23][INFO][0x0015a] it's here and it's optimally required start index[1] , length[15]
Time is here [Tick:135055] , Time: 17, index: 608, CastedType:20002, area :0
[#15:23][INFO][0x0015a] it's here and it's optimally required start index[1] , length[15]
[#16:25][PERFECT][0x0015a] process returned as NULL load index[1] , length[20] , type[0]
[#17:3][INFO][0x0015a] it's here and it's optimally required start index[1] , length[15]
[#8:23][INFO][0x0015a] it's here and it's optimally required start index[1] , length[15]
time is here [Tick:135055] , Time: 17, index: 608, CastedType:20002, area :0
[#16:23][INFO][0x0015a] it's here and it's optimally required start index[1] , length[15]
[#14:25][PERFECT][0x0015a] process returned as NULL load index[1] , length[20] , type[0]
[#18:3][INFO][0x0015a] it's here and it's optimally required start index[1] , length[15]
[#6:23][INFO][0x0015a] it's here and it's optimally required start index[1] , length[15]
Time is here [Tick:135055] , Time: 17, index: 608, CastedType:20002, area :0
Results/output of the function:
1. Generating txt file that has all rows of the **certain pattern** that I explained above (all rows that has word **[PERFECT]** so the generated txt file shall be having all messages / rows that has **[PERFECT]** :
Code:
[#12:25]**[PERFECT]**[0x0015a] process returned as NULL load index[1] , length[20] , type[0]
[#16:25]**[PERFECT]**[0x0015a] process returned as NULL load index[1] , length[20] , type[0]
[#14:25]**[PERFECT]**[0x0015a] process returned as NULL load index[1] , length[20] , type[0]
2. Then generating a another new txt file for the load index values which in my case load index values found inside [ ] of the word load index ( load index [value] ), so the function shall dump in new txt file the values of the load index **as column** into the another new generated txt file :
1
1
1
How to parse and implement in python that function functionality?
thanks alot for any cooperation !