data for card printing
This commit is contained in:
37
scripts/card_print_data.py
Normal file
37
scripts/card_print_data.py
Normal file
@@ -0,0 +1,37 @@
|
||||
import pandas as pd
|
||||
import os
|
||||
import numpy as np
|
||||
import xlsxwriter
|
||||
|
||||
curdir = os.getcwd()
|
||||
path_delim = '/'
|
||||
df1 = pd.read_excel(curdir + path_delim + "data/users_16_12_2023_18_31.xlsx", sheet_name="Sheet1")
|
||||
df2 = pd.read_excel(curdir + path_delim + "data/16Dec23-GIPCI Card Printing-2.xlsx", sheet_name="Data for Submission-GIPCI 16Dec")
|
||||
|
||||
df = df2.merge(df1, on="_id", how="inner")
|
||||
print(df.columns)
|
||||
|
||||
# df = df[["_id", "name_x", "abhaId", "aadharId", "Age", "gender", "category", "maritalStatus", "house", "district", "state", "pinCode", "phoneNumber", "classificationResult", "bloodGroup", "testTime", "caste", "registrationCenterName"]]
|
||||
# print(df)
|
||||
|
||||
df["Block/Ward"] = ""
|
||||
df["Village/Town/City"] = df["city"]
|
||||
df["Test Type"] = "HPOS"
|
||||
df["Photograph"] = df['_id'].apply(lambda x: f'images\{x}.jpg') #f"external:{row['Image URL']}"
|
||||
|
||||
df.rename(columns={'_id': "Sample ID", "ABHA ID": "ABHA Number", "careOf": "Father's Name / Husband's Name", "Test Result": "Test report"}, inplace = True)
|
||||
|
||||
df = df.reindex(["Sample ID", "ABHA Number", "Name", "Age", "Gender", "Father's Name / Husband's Name", "District", "Block/Ward", "Village/Town/City", "Address", "Pincode", "Test report", "Test Type", "Blood Group", "bloodGroup", "Photograph"], axis=1)
|
||||
|
||||
writer = pd.ExcelWriter(curdir + path_delim + "data/CardPrint3.xlsx", engine = 'xlsxwriter')
|
||||
df.to_excel(writer, sheet_name = 'op', index=False)
|
||||
|
||||
# Get the xlsxwriter workbook and worksheet objects
|
||||
workbook = writer.book
|
||||
worksheet = writer.sheets['op']
|
||||
|
||||
# Add hyperlinks to the 'Photograph' column
|
||||
for row_num, link in enumerate(df['Photograph'], start=1):
|
||||
worksheet.write_url(row_num, df.columns.get_loc('Photograph'), string='Link', url=link, cell_format=None)
|
||||
|
||||
writer.close()
|
||||
Reference in New Issue
Block a user