Mar-14-2023, 07:59 PM
Hello dear pythonians ,
I have an excel file which containers qr code each in separate line ( see photo attached)
I need to do some processing to extract the data from these QR codes then write the results in another excel file which container the final data after processing.
I have written most of the code except the final stage( write and append to final excel file) where I got stuck :woozy_face: :cold_sweat: -
Here is the code
I want to loop over all QR codes and append data in a new excel file which contain the header details I already wrote at the beginning.
Here is an example of QR code for testing :–
ASFBcm5vbiBQbGFzdGljIEluZHVzdHJpZXMgQ28uIEx0ZC4CDzMwMDQ5ODYwOTkwMDAwMwMTMjAyMy0wMi0xNCAxMjo0ODoxMwQHNDYwMC4wMAUGNjAwLjAw
Rgds,
Jenni
I have an excel file which containers qr code each in separate line ( see photo attached)
I need to do some processing to extract the data from these QR codes then write the results in another excel file which container the final data after processing.
I have written most of the code except the final stage( write and append to final excel file) where I got stuck :woozy_face: :cold_sweat: -
Here is the code
import pandas as pd import openpyxl import tlv8 import base64 #create new excel file with header for final output df = pd.DataFrame( columns=["Seller Name","Vat Number","Invoice Date","Total Amount","Vat Amount"]) df.to_excel("final.xlsx",index=False) # load excel containing qr code with its path for reading wrkbk = openpyxl.load_workbook("G:\\qr.xlsx") sh = wrkbk.active # iterate through QR code excel file to input the data for processing for row in sh.iter_rows(): for cell in row: base64QR=cell.value rawByte = base64.b64decode(base64QR) str1 = rawByte.decode('UTF-8') 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) Data_List = [entry.data for entry in final_output] final_list = [] for ele in Data_List: final_list.append(ele.strip()) print(final_list) # final output is a list # final output looks like below : # ['Arnon Plastic Industries Co. Ltd.', '300498609900003', '2023-02-14', 4600.0, 600.0]My question is :–
I want to loop over all QR codes and append data in a new excel file which contain the header details I already wrote at the beginning.
Here is an example of QR code for testing :–
ASFBcm5vbiBQbGFzdGljIEluZHVzdHJpZXMgQ28uIEx0ZC4CDzMwMDQ5ODYwOTkwMDAwMwMTMjAyMy0wMi0xNCAxMjo0ODoxMwQHNDYwMC4wMAUGNjAwLjAw
Rgds,
Jenni