Mar-13-2023, 09:07 PM
Hello ,
I'm a python junior developer and I have a task to accomplish. I have a QR code which is made of TLV value encoded in base 64.
I have to parse this QR code to extract the values ( they are 5 ) and export the values into excel sheet , then do some math on some numbers ( the 4th and 5th value are floats ).
To achieve this task , I used 2 modules :
tlv8
base64
Here is the full code
[
<1, Arnon Plastic Industries Co. Ltd.>,
<2, 300498609900003>,
<3, 2023-02-14 12:48:13>,
<4, 4600.00>,
<5, 600.00>,
]
I want to be able to extract the data from each field and convert them ( strings for 1st,2nd , date for 3rd , 4th,5th to be float ).
I don't want to include space or > symbol appear at the end of each field. I also don't want the serials numbers at beginning.
The final job is to extract these values into excel sheet and calculate the values in forth columns at the end.
I would appreciate if anyone could help me.
Thanks and regards,
Jennifer
I'm a python junior developer and I have a task to accomplish. I have a QR code which is made of TLV value encoded in base 64.
I have to parse this QR code to extract the values ( they are 5 ) and export the values into excel sheet , then do some math on some numbers ( the 4th and 5th value are floats ).
To achieve this task , I used 2 modules :
tlv8
base64
Here is the full code
import tlv8 import base64 base64QR= "ASFBcm5vbiBQbGFzdGljIEluZHVzdHJpZXMgQ28uIEx0ZC4CDzMwMDQ5ODYwOTkwMDAwMwMTMjAyMy0wMi0xNCAxMjo0ODoxMwQHNDYwMC4wMAUGNjAwLjAw" rawByte = base64.b64decode(base64QR) structure1 = { 1: tlv8.DataType.STRING, 2: tlv8.DataType.STRING, 3: tlv8.DataType.STRING, 4: tlv8.DataType.STRING, 5: tlv8.DataType.STRING } final_output = tlv8.decode(rawByte, structure1) str_output= tlv8.format_string(final_output) print(str_output)This will result in the following output :
[
<1, Arnon Plastic Industries Co. Ltd.>,
<2, 300498609900003>,
<3, 2023-02-14 12:48:13>,
<4, 4600.00>,
<5, 600.00>,
]
I want to be able to extract the data from each field and convert them ( strings for 1st,2nd , date for 3rd , 4th,5th to be float ).
I don't want to include space or > symbol appear at the end of each field. I also don't want the serials numbers at beginning.
The final job is to extract these values into excel sheet and calculate the values in forth columns at the end.
I would appreciate if anyone could help me.
Thanks and regards,
Jennifer