0
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
Austin
  • 25,759
  • 4
  • 25
  • 48
Girish K
  • 1
  • 1

1 Answers1

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