MrO
New Coder
I will admit i am not very good with python, but what i set out to do i thought was very easy. i learn by example, and i can figure almost anything out eventually and im sure i will after enough time, but man at the moment i am so lost lol. basically i need to pull the name of all the characteristics, and their description from a node in an a2l file or even a txt file saved from the a2l, and save it to a json file in a simple format.
here is the layout of one of many CHARACTERISTICs in the a2l:
/begin CHARACTERISTIC
ABOMX
"max. numbers of starts for recognition of fuel in oil"
VALUE
0x1D86AE
KwUb
255.0
dez
0.00
255.0
FORMAT "%5.1"
/begin IF_DATA ASAP1B_CCP DP_BLOB 0x00 0x5D86AE 1 /end IF_DATA
/begin IF_DATA ETK DP_BLOB 0x9186AE 0x1 /end IF_DATA
/begin IF_DATA ASAP1B_KWP2000 DP_BLOB 0x5D86AE 0x1 /end IF_DATA
/end CHARACTERISTIC
i simply need to pull the second line after /begin CHARACTERISTIC (ABOMX) and the third line ("max. numbers of starts for recognition of fuel in oil") and output them into a JSON file in the format of:
"ABOMX": "max. numbers of starts for recognition of fuel in oil",
then move to the next characteristic in the a2l file and do the same, output to a JSON or even just a txt file with the ID and DEFINITION, but indented to next line so its all pretty and nice like. essentially making a list of the characteristics id's and their definitions. i realize i clearly need to learn more about python, and ive actually gotten myself 3 books to read in my free time to learn basic python haha. but i feel like this isn't a super complex thing to achieve. and im getting so tired of doing it all by hand. Im having a hard time wrapping my head around parsing through and pulling only certain lines. If anyone could point me in the right direction, or give me an example of how to go about pulling specific lines after /begin CHARACTERISTIC, and then outputting them in the "NAME": "DEFINITION", format, or even slightly help nudge me closer to my end goal, i would be crazy thankful. anyway, thanks for taking the time to read all this.
here is the layout of one of many CHARACTERISTICs in the a2l:
/begin CHARACTERISTIC
ABOMX
"max. numbers of starts for recognition of fuel in oil"
VALUE
0x1D86AE
KwUb
255.0
dez
0.00
255.0
FORMAT "%5.1"
/begin IF_DATA ASAP1B_CCP DP_BLOB 0x00 0x5D86AE 1 /end IF_DATA
/begin IF_DATA ETK DP_BLOB 0x9186AE 0x1 /end IF_DATA
/begin IF_DATA ASAP1B_KWP2000 DP_BLOB 0x5D86AE 0x1 /end IF_DATA
/end CHARACTERISTIC
i simply need to pull the second line after /begin CHARACTERISTIC (ABOMX) and the third line ("max. numbers of starts for recognition of fuel in oil") and output them into a JSON file in the format of:
"ABOMX": "max. numbers of starts for recognition of fuel in oil",
then move to the next characteristic in the a2l file and do the same, output to a JSON or even just a txt file with the ID and DEFINITION, but indented to next line so its all pretty and nice like. essentially making a list of the characteristics id's and their definitions. i realize i clearly need to learn more about python, and ive actually gotten myself 3 books to read in my free time to learn basic python haha. but i feel like this isn't a super complex thing to achieve. and im getting so tired of doing it all by hand. Im having a hard time wrapping my head around parsing through and pulling only certain lines. If anyone could point me in the right direction, or give me an example of how to go about pulling specific lines after /begin CHARACTERISTIC, and then outputting them in the "NAME": "DEFINITION", format, or even slightly help nudge me closer to my end goal, i would be crazy thankful. anyway, thanks for taking the time to read all this.