0
I need to extract information from a cell in excel using pandas and pyautogui. The cell has a date contained and accurate take out the numbers without the "/" bars. Example: 25/12/2000.
What I do at the moment is to look at what the user typed in the cell date of birth and manually separate the numbers 25, 12 and 2000 in other 3 cells (day month of year)and use the pandas to access these 3 cells and get the desired effect, as direct access with pandas to cellula date of birth?
Today I manually set and separate the date into 3 cells and search the information in these cells
My Spreadsheet:
A B C D E F #transformo a celula C em D, E e F
1 nome sobrenome data de nascimento dia mes ano
2 Joao Mendes 25/12/2000 25 12 2000
I want a function that searches the information of day, month and year of the Cell date of birth and bring me that information one at a time and not all at once.
import pyautogui import pandas as pd
formulario = pd.read_excel(r'C:\formulario.xlsx', sheet_name='Planilha1')
## Uma amostra de dados para teste...
#formulario = pd.DataFrame({
# 'nome':['João'],
# 'sobrenome':['Mendes'] ,
# 'data de nascimento': ['25/12/2000']
#})
for i in range(1):
pyautogui.write(str(formulario['dia'] [0]))
pyautogui.write(str(formulario['mes'] [0]))
pyautogui.write(str(formulario['ano'] [0]))
Solved:
import pandas as pd
df = pd.DataFrame({'data de nascimento': ['25/12/2000']})
data = df['data de nascimento'] [0]
dia = data[:2]
mes = data[3:5]
ano = data[6:]
print(dia)
print(mes)
print(ano)
I want to use 'date of birth' data and not create 'day' month and 'year'. I want some command that reads only the day, then the month and then the year and can print it in the program.
– G̶e̶r̶a̶l̶d̶o̶ J̶u̶n̶i̶o̶r̶
Take another look at example I made a modification and see if that’s what you want to do.
– Augusto Vasques
I was able to solve it like this:
import pandas as pd
df = pd.DataFrame({'data de nascimento': ['25/12/2000']})

data = df['data de nascimento'] [0]
dia = data[:2]
mes = data[3:5]
ano = data[6:]

print(dia)
– G̶e̶r̶a̶l̶d̶o̶ J̶u̶n̶i̶o̶r̶