I have an script but the idea for this script is to read multiples excel files, itś possible to read with a parameter? or another idea, the most important is that people who use the script dont write or open the script and define or write the path for the excel file. I use this script with selenium
excel_credenciales = '/home/.../.../prueba.xlsx' #i need to change this part
df = pd.read_excel(excel_credenciales)
mylist = df['url'].tolist()
cont = 1 #inicializar contador en 1
#acciones que debe hacer
for url in mylist:
driver.get(url)
driver.maximize_window()
driver.implicitly_wait(val)
timestamp = datetime.datetime.now().strftime('%d_%m_%Y')
CodePudding user response:
I don't know if I understand the question right but there are some solutions for this:
You can walk through the files in your desired folder and get the file path and put it in
excel_credenciales
using os.walk function. Also, you can make this as a function and in docs of that function specify to store the files in specific folder in relative manner like: store the files in ../excel_files.If you have name of the files stored, you can use f strings like this
f'/home/{some_folder}/{another_folder}/{name_of_the_file}.xlsx'
CodePudding user response:
you can use pandas library by :
import pandas as pd
then you have to make sure the location of your excel file to initialize the excel_credenciales variable, the most important thing is the correct file path
if your excel file is in the same hierarchy as your python file then its use can be done like this example
excel_credenciales = 'prueba.xlsx'
df = pd.read_excel(excel_credenciales)
but if your file is in an external folder you can add the path ../ before the filename
example excel_credenciales = '../prueba.xlsx'