I have a xlsx file with game names, their prices and the links to their sites where we can find them. I'm trying to make a program where someone can type one word and the program will search for every game with this word in its name and show its price and link.
nome preco link
0 Fifa 20 R$ 164,90
1 FIFA 19 R$ 84,90 https://www.americanas.com.br/produto/13379718...
2 EFootball PES 2020 R$ 93,88 https://www.americanas.com.br/produto/13456974...
3 Forza Horizon 4 R$ 199,90 https://www.americanas.com.br/produto/13379732...
4 Mortal Kombat 11 R$ 129,90 https://www.americanas.com.br/produto/13416378...
Since I'm a beginner I don't know how to start, even though I already tried regex. Could someone help me? Thank you
I would use pandas to import and search, then loop through the results and print your output.
import pandas as pd
df = pd.read_excel('64653127.xlsx')
search = 'fifa'
#use str.lower() for case insensitive results
results = df[df['nome'].str.lower().str.contains(search)]
#print(results)
for index, row in results.iterrows():
print(str(row['nome']) + ' link: ' + str(row['link']))
The output is:
Fifa 20 link: nan
FIFA 19 link: https://www.americanas.com.br/produto/13379718...