diff --git a/scripts/card_print_1.js b/scripts/card_print_1.js new file mode 100644 index 0000000..5e3a6a5 --- /dev/null +++ b/scripts/card_print_1.js @@ -0,0 +1,43 @@ + + +function main(workbook: ExcelScript.Workbook) { + let selectedCell = workbook.getActiveCell(); + let selectedSheet = workbook.getActiveWorksheet(); + + // Set fill colour to yellow for the selected cell. + selectedCell.getFormat().getFill().setColor("yellow"); + + // Get the hyperlink of the active cell. + let hyperlink = selectedCell.getHyperlink(); + + // Print the hyperlink in the console. + // console.log("Hyperlink: " + JSON.stringify(hyperlink.address)); + + // Check if there is a selected cell. + if (selectedCell) { + // Get the column index of the selected cell. + let selectedColumnIndex = selectedCell.getColumnIndex(); + + // Get the active sheet. + let selectedSheet = workbook.getActiveWorksheet(); + + // Get the number of rows in the sheet. + let rowCount = 10932; + + // Iterate through each row and copy the value from the selected column to a new column. + for (let rowIndex = 0; rowIndex < rowCount; rowIndex++) { + // Get the value from the selected column. + let cellValue = selectedSheet.getCell(rowIndex, selectedColumnIndex).getHyperlink()?.address; + + // Assume the new column is next to the selected column. You can adjust the index as needed. + let newColumnIndex = selectedColumnIndex + 1; + + // Set the value in the new column. + selectedSheet.getCell(rowIndex, newColumnIndex).setValue(cellValue); + } + + console.log("New column created with values from the selected column."); + } else { + console.log("No cell selected."); + } +} diff --git a/scripts/card_print_data_2.py b/scripts/card_print_data_2.py new file mode 100644 index 0000000..631b518 --- /dev/null +++ b/scripts/card_print_data_2.py @@ -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", "aadharId": "AADHAAR 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", "AADHAAR ID", "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/CardPrint4.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() \ No newline at end of file diff --git a/scripts/card_print_data_3.py b/scripts/card_print_data_3.py new file mode 100644 index 0000000..1698590 --- /dev/null +++ b/scripts/card_print_data_3.py @@ -0,0 +1,75 @@ +import pandas as pd +import os + +curdir = os.getcwd() +path_delim = '/' +df1 = pd.read_excel(curdir + path_delim + "data/users_12_01_2024_23_25.xlsx", sheet_name="Sheet1") +df2 = pd.read_excel(curdir + path_delim + "data/12jan-printing-input.xlsx", sheet_name="Sheet1") + +# Define a function to find the _id for each row in df2 +def find_id(row): + match = df1[(df1['abhaId'] == row['abhaId'])] + if not match.empty: + return match.iloc[0]['_id'] + else: + match = df1[(df1['name'] == row['name'])] + if not match.empty: + return match.iloc[0]['_id'] + match = df1[(df1['house'] == row['address'])] + if not match.empty: + return match.iloc[0]['_id'] + return None + +def find_aadharId(row): + match = df1[(df1['abhaId'] == row['abhaId'])] + if not match.empty: + return match.iloc[0]['aadharId'] + else: + match = df1[(df1['name'] == row['name'])] + if not match.empty: + return match.iloc[0]['aadharId'] + match = df1[(df1['house'] == row['address'])] + if not match.empty: + return match.iloc[0]['aadharId'] + return None + +def find_abhaId(row): + match = df1[(df1['name'] == row['name'])] + if not match.empty: + return match.iloc[0]['abhaId'] + else: + match = df1[(df1['house'] == row['address'])] + if not match.empty: + return match.iloc[0]['abhaId'] + return None + +# Apply the function to create a new '_id' column in df2 +df2['_id'] = df2["Photograph"].get_url() +df2['aadharId'] = df2.apply(find_aadharId, axis=1) +df2['abhaId2'] = df2.apply(find_abhaId, axis=1) + +# Continue with the rest of your code... + +# Add the rest of your code (e.g., renaming columns, creating new columns, etc.) +df2["Block/Ward"] = "" +# df2["Village/Town/City"] = df2["city"] +df2["Test Type"] = "HPOS" +df2["Photograph"] = df2['_id'].apply(lambda x: f'images\{x}.jpg') + +df2.rename(columns={'_id': "Sample ID", "name": "Name", "aadharId": "AADHAAR ID", "ABHA ID": "ABHA Number", "careOf": "Father's Name / Husband's Name", "Test Result": "Test report"}, inplace=True) + +# Continue with the rest of your code... + +# Save the resulting DataFrame to Excel +writer = pd.ExcelWriter(curdir + path_delim + "data/CardPrint10.xlsx", engine='xlsxwriter') +df2.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(df2['Photograph'], start=1): + worksheet.write_url(row_num, df2.columns.get_loc('Photograph'), string=link, url=link, cell_format=None) + +writer.close() diff --git a/scripts/card_print_data_4.py b/scripts/card_print_data_4.py new file mode 100644 index 0000000..473d983 --- /dev/null +++ b/scripts/card_print_data_4.py @@ -0,0 +1,26 @@ +import pandas as pd +import os +import re + +curdir = os.getcwd() +path_delim = '/' +df = pd.read_excel(curdir + path_delim + "data/12jan-printing-input.xlsx", sheet_name="Sheet1") + + +pattern = re.compile(r'/([^/]+)\.[a-z]+$', re.IGNORECASE) + +# Function to apply to each row of the DataFrame +def extract_filename(file_path): + match = pattern.search(file_path) + return match.group(1) if match else None + +# Apply the function to the 'file_path' column +df['_id'] = df['Url'].apply(extract_filename) + +print(df) +print(df.columns) + +writer = pd.ExcelWriter(curdir + path_delim + "data/CardPrint11.xlsx", engine='xlsxwriter') +df.to_excel(writer, sheet_name='op', index=False) + +writer.close() diff --git a/scripts/card_print_data_5.py b/scripts/card_print_data_5.py new file mode 100644 index 0000000..cce6c9f --- /dev/null +++ b/scripts/card_print_data_5.py @@ -0,0 +1,14 @@ +import os +import re + +file_path = "../../../../Downloads/images/352405884025RAVGMC.jpg" + +# Using regular expression to extract the filename without extension +pattern = re.compile(r'/([^/]+)\.[a-z]+$', re.IGNORECASE) +match = pattern.search(file_path) + +if match: + extracted_file_name = match.group(1) + print(extracted_file_name) +else: + print("Unable to extract filename from the given path.") \ No newline at end of file diff --git a/scripts/card_print_data_6.py b/scripts/card_print_data_6.py new file mode 100644 index 0000000..686ed7a --- /dev/null +++ b/scripts/card_print_data_6.py @@ -0,0 +1,35 @@ +import pandas as pd +import os + +curdir = os.getcwd() +path_delim = '/' +df1 = pd.read_excel(curdir + path_delim + "data/users_12_01_2024_23_25.xlsx", sheet_name="Sheet1") +df2 = pd.read_excel(curdir + path_delim + "data/CardPrint11.xlsx", sheet_name="op") + +df = df2.merge(df1, on="_id", how="left") +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", "aadharId": "AADHAAR 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", "AADHAAR ID", "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/CardPrint12.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() \ No newline at end of file