Как разобрать массив C в файле .c с помощью скрипта Python?
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[] = { //-------------------------// //| Rank | Stat | Level | Stance | // { 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:
Что я уже пробовал:
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>.
Формат xml показан ниже:
<League name="PrimierLeague/Information/**STAT**" TeamType="Team" visibility="false"> <Description>**Level**</Description> <Target><Property/></Target> <Info type="String">EMPTY</Info> </League >
Member 13048699
Xml имеет формат follwinf. Я не мог пройти мимо всего этого там, наверху.
<имя-Лига="PrimierLeague/информации/**срочно**" TeamType="команда" видимость="ложно"и GT;
< описание> * * уровень**
< target> & lt; property>
< Info type= "String" & gt;пусто
< / Лига >
CPallini
Альтернативой может быть создание программы на языке Си, производящей вывод XML.