How can I make a script to search information in a spreadsheet? [Python] #130426
Replies: 3 comments
-
Need more info on "Issues with code printing out results" |
Beta Was this translation helpful? Give feedback.
-
import pandas as pd Load the spreadsheet data into a Pandas dataframedf = pd.read_excel('spreadsheet.xlsx') Combine columns A and B into a query stringquery = df['A'] + ' ' + df['B'] Search through the rest of the columns using the query stringresults = df[df.columns[2:]].apply(lambda x: x.str.contains(query), axis=0) Define the API endpoints and CSE IDsapi_endpoints = ['https://api1.com/search', 'https://api2.com/search', ...] Loop through the APIs and CSE IDsfor api_endpoint, cse_id in zip(api_endpoints, cse_ids): |
Beta Was this translation helpful? Give feedback.
-
Step 1: Read the spreadsheet data (use openpyxl or gspread) Have a good day! |
Beta Was this translation helpful? Give feedback.
-
Body
Hi! I am semi comfortable with using python. Currently I am trying to make a script to search for information in a spreadsheet. Column A and B need to be combined into a query, and then searched with the rest of the column headers. Think of google dorking!
I already have ten APIs and ten CSE ids but I am just unsure of what is the best way to approach this. I have tried to use ChatGPT and Gemini to help in both using excel and google scripts but I keep having issues with the code printing out the results correctly. Any help or direction will be appreciated. Thanks!
Guidelines
Beta Was this translation helpful? Give feedback.
All reactions