I have a .c file and it contains several arrays. I need to parse a specific array which has the following name: s_InfoDay day_stat[] = { ... };
My python script has to be able to read this .c file and look for this specific array and perform the process on it. The c array has information in the following format:
s_InfoDay day_stat[] = {
{ 0 , "ALPHA", "NOTPRESENT", "NOTPRESENT" },
{ NA , "LAURA", "UNKNOWN", "UNKNOWN" },
{ 1 | LEAGUE_1 , "MANU" , "SECOND", "ONGOING" },
{ 2 | LEAGUE_2 , "MANU" , "SECOND", "ONGOING" },
{ 1 | TEAM_3 | (1<<3), "CHELSEA", " FIRST", "WINNERS" },
{ 3 |(1<<3) | TEAM_3 , "CHELSEA", " FIRST", "WINNERS" },
{ 0 , NULL , NULL , NULL } } ;
The array contains almost 500 lines and it has data in this specific format. I only want to be able to extract the values under the | Stat | Level | and able to place the in the form of an xml like structure for display purposes.
The xml tags has the following fixed format. I will have a group of 500 of these tags which have the correct values in the stat and level section in the xml tag below:
What I have tried:
Whenever I parse each line the array, I need to be able to place the string in " " under the Stat in the location of the STAT in the PrimierLeague/Information/STAT and same for the Level in the tag <Description>**Level**</Description>.
The xml format is shown below:
<League name="PrimierLeague/Information/**STAT**" TeamType="Team" visibility="false">
<Description>**Level**</Description>
<Target><Property/></Target>
<Info type="String">EMPTY</Info>
</League >