import pandas as pd
from easygui import *
df = pd.read_csv('allfoods.csv')
choices = ["Egg", "Milk" ]
choice = multchoicebox(msg, title, choices)
if choice == "Egg" :
df2 = df[df.Food=="Egg"].head()
print (df2)
df2.to_csv('outfile.csv', encoding='utf-8', index=False, header=False)
if choice == "Milk" :
df3 = df[df.Food=="Milk"].head()
print (df3)
df3.to_csv('outfile.csv', encoding='utf-8', index=False, header=False)
else: pass
Asked
Active
Viewed 21 times
0
1 Answers
0
Looks like the change below fixed it.
choice = multchoicebox(msg, title, choices) print ("Reply was: %s" % str(choice))
for i in range(len(choice)):
print (choice[i]) df1 = df[df.Food==choice[i]].head() print (df1)
df1.to_csv('outfile.csv', encoding='utf-8', index=False, mode='a', header=False)

Girish K
- 1
- 1