Jul-10-2018, 05:30 PM
(Jul-08-2018, 11:07 PM)carpe Wrote:Quote:Could you please give me a rough outline of option 1? To show me what I need to progress to. It would be much appreciated as I have small experience in python.
Assuming the original text file looks something similar to...
Member ID Surname Year Joined Membership Status Nights Booked Points Balance
Gri33415 Griffiths 2015 Gold 35 40000
Smi22316 Smith 2016 Silver 3 7500
Mia56213 Miah 2013 Platinum 140 165000
...
tThen something like...
import pandas as pd def read_text(): data_frame = pd.read_csv("/path/to/relevant/file/textfile.txt", sep=" ", skiprows=[0], header=None) data_frame.columns = ["Member ID", "Surname", "Year Joined", "Membership Status", "Nights Booked", "Points Balance"] return data_frame... should get the data loaded in and ready to use.
Hello again!
Panda is not installed on the school computers and I cannot get it installed, meaning that the code is invalid!
I have a text.txt file saved within my drive and also on the document, I need to make a function so that it displays in the correct parameters of ID, Name, etc. This is my text file:
(Text.txt)
[Gri33415,Griffiths,2015,Gold,35,40000] [Smi77316,Smith,2016,Silver,3,7500] [Mia56213,Miah,2013,Platinum,140,165000]
[All78915,Allen,2015,Platinum,120,145000] [Hug91714,Huggett,2014,Platinum,150,50000] [Sel77617,Selby,2017,Gold,40,45000]
[San55614,Santus,2014,Silver,17,30000] [Lee44213,Leewah,2013,Silver,15,37500]
Can you help me to find some code that will make a def function to run this when someone selects an option from my menu, please. I am really stuck: Here is my menu, if some code is provided, could you also tell me where I need to put the code and anything else I need to do to make it run when the user selects the option to show members, Thanks!
print("???????????????")
print("?? A: Add new member ??")
print("? B: Book a night. ??")
print("?? C: Redeem points ??")
print("? D: Show members. ??")
print("?? E: Quit ??")
print("????????????????")
answer =str.lower(input(("Please select an option")))
if answer == "a":
print("Okay, lets start")
elif answer == "b":
print("Okay, lets start")
elif answer == "c":
print("Okay, lets start")
elif answer == "d":
print("Okay, lets start")
elif answer == "e":
print("Exited")
else:
print("Invalid")