Skip to content

Instantly share code, notes, and snippets.

@ashhadulislam
Created March 4, 2026 07:40
Show Gist options
  • Select an option

  • Save ashhadulislam/e932436dbe8a6edef4e3270c333dc621 to your computer and use it in GitHub Desktop.

Select an option

Save ashhadulislam/e932436dbe8a6edef4e3270c333dc621 to your computer and use it in GitHub Desktop.
file_identifier='2026-EROLLGEN-S25-161-SIR-FinalRoll-Revision1-ENG-136-WI'
base_folder=f'/Users/ashhadulislam/projects/social/SIR/namecard_sets/{file_identifier}'
answer_list=[]
counter=0
for f in os.listdir(base_folder):
#print(f)
image_file_location=f'{base_folder}/{f}'
with open(image_file_location, "rb") as img_file:
base64_image = base64.b64encode(img_file.read()).decode("utf-8")
data_url = f"data:image/png;base64,{base64_image}"
answer=namecard_info_extract(openrouter_api_key,namecard_info_extractor_prompt,data_url)
answer['file_identifier']=file_identifier
answer['file_name']=f
answer_list.append(answer)
counter+=1
if counter%50==0:
print(counter,'/',len(os.listdir(base_folder)),time.time())
import pandas as pd
cleaned_answer_list = clean_answer_list(answer_list)
df=pd.DataFrame(cleaned_answer_list)
df=df.sort_values(by=['file_name'])
save_folder='/Users/ashhadulislam/projects/social/SIR/output_sheets'
df.to_csv(f'{save_folder}/{file_identifier}.csv',index=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment