Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 3rd, 2004, 01:37 AM
Jackity84 Jackity84 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 36 Jackity84 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 48 m 23 sec
Reputation Power: 5
Need help.. Reading datas..

I have a data file containing grades of made up students and i'm trying to make a program that reads this data and outputs the grades.. so how do i do that?

Reply With Quote
  #2  
Old December 3rd, 2004, 02:46 AM
Jackity84 Jackity84 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 36 Jackity84 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 48 m 23 sec
Reputation Power: 5
So far i have...
Code:
import gradelist
data = gradelist.read()
entry = input("Administration Password: ")
for entry in data:
    print entry[0]
if entry == 165:
    print entry[0]
else:
    print "Wrong password"
print "</body>" 


but it says entry[0] unscriptbable object...

Reply With Quote
  #3  
Old December 3rd, 2004, 03:02 AM
Jackity84 Jackity84 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 36 Jackity84 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 48 m 23 sec
Reputation Power: 5
oops that last line <body> not suppose to be there.. but what im trying to do is set a password to view the grades from the data file which i have stored in the same folder as my program... but not working

Reply With Quote
  #4  
Old December 3rd, 2004, 04:32 AM
NewPythoner NewPythoner is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Bombay, India
Posts: 159 NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 43 m 45 sec
Reputation Power: 7
Send a message via Yahoo to NewPythoner
Hi,
Whats this
Code:
import gradelist


I'm not getting it clearly. You've a text file containing just the grades or additional info too.

Next is it, only authorized users r given access to view the grades or tamper with it... be more clear pls

Rgds,
Subha

Reply With Quote
  #5  
Old December 3rd, 2004, 04:49 AM
Jackity84 Jackity84 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 36 Jackity84 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 48 m 23 sec
Reputation Power: 5
Sorry...
Here's what im trying to do..
I have a module already called gradelist and in this module is has 2 functions. 1.gradelist.write(list): Write the data from the grade list list to a file names grades.data in the current directory.
2. data = gradelist.read(): Read the data from grades.data and return the grade list.

and what im trying to do is when the user types in 165 (that's password) it'll show all the data in the gradelist module... that clear now?

Reply With Quote
  #6  
Old December 3rd, 2004, 05:40 AM
NewPythoner NewPythoner is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Bombay, India
Posts: 159 NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 43 m 45 sec
Reputation Power: 7
Send a message via Yahoo to NewPythoner
Hi,

Am pretty sure u don't want the below.... u r mature enough for that one.

Code:
>>> pw=input("Admin Password")
>>> data=[23,45,67,35,76]
>>> if pw!=165:
... 	print "Invalid Password!"
... else:
... 	for entry in data:
... 		print entry
... 
23
45
67
35
76


Since u say, data gets the list...the gradelist... so cld u give an example of how the list looks... is it like an array or something? Since u r using this entry[0], am not clear with it...maybe a well-experienced person is reqd to decipher all this... but just let me try too... so all the doubt in the air wld be clear if u give a small example of how ur list looks like


Subha

Reply With Quote
  #7  
Old December 4th, 2004, 04:52 AM
Jackity84 Jackity84 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 36 Jackity84 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 48 m 23 sec
Reputation Power: 5
mmmk sorry am not too good with this..
but when the user types in 165, it should display this:
["userid", 10, "Comments" ] The first entry in the list is the student's userid, the second is their mark (an integer) and the last is a string containing comments.
so ex: ['astudent', 100, 'Very well done.'] would be one of them..so the entire grade list would be a list of those..
and for the
Code:
for entry in data:
    print entry[0]

this loop will output the userids of all the students in the grade list grades. Hope this helps.. im still stuck

Reply With Quote
  #8  
Old December 4th, 2004, 05:06 AM
NewPythoner NewPythoner is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Bombay, India
Posts: 159 NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 43 m 45 sec
Reputation Power: 7
Send a message via Yahoo to NewPythoner
Hmmm still let me try... but I think ur program shd work fine...everythings clear except one prob

Code:
entry = input("Administration Password: ")
for entry in data:


try using a different variable to catch the password. Who knows ...may make a difference

Code:
>>> gradeList=[['Dexter',100,'Excellent!'],['DeeDee',50,'Satisfactory!'],['Bubbles',20,'Poor!']]
>>> gradeList
[['Dexter', 100, 'Excellent!'], ['DeeDee', 50, 'Satisfactory!'], ['Bubbles', 20, 'Poor!']]
>>> gradeList[0]
['Dexter', 100, 'Excellent!']
>>> for entry in gradeList:
... 	entry[0]
... 	
'Dexter'
'DeeDee'
'Bubbles'
>>> 


Is this what u need? But I doubt

Report back!

Peace,
Subha

Reply With Quote
  #9  
Old December 4th, 2004, 05:16 AM
Jackity84 Jackity84 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 36 Jackity84 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 48 m 23 sec
Reputation Power: 5
hey yea, the 2nd code that you wrote is what the teacher gave us as example.. so im still lost.. dunno what to do.

Reply With Quote
  #10  
Old December 4th, 2004, 05:21 AM
Jackity84 Jackity84 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 36 Jackity84 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 48 m 23 sec
Reputation Power: 5
Hey,

since you know how to do this, wanna exchange msn (if you have it), so you could help me out? That is, if you have time, if not that's coo we can keep replying on forum..

Thanks ~!!

Reply With Quote
  #11  
Old December 4th, 2004, 05:25 AM
NewPythoner NewPythoner is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Bombay, India
Posts: 159 NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 43 m 45 sec
Reputation Power: 7
Send a message via Yahoo to NewPythoner
yes I do have msn. But can't use it while I'm working
I wld go with your second option...on the forum

Subha

Reply With Quote
  #12  
Old December 4th, 2004, 05:26 AM
Jackity84 Jackity84 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 36 Jackity84 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 48 m 23 sec
Reputation Power: 5
Alright cool

so what should my code look like right now? im confuse because am i suppose to put that 2nd code u wrote down?

Reply With Quote
  #13  
Old December 4th, 2004, 05:31 AM
Jackity84 Jackity84 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 36 Jackity84 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 48 m 23 sec
Reputation Power: 5
k here's what the form looks like

http://cmpt165.cs.sfu.ca/~jju/as4.html

Reply With Quote
  #14  
Old December 4th, 2004, 05:32 AM
NewPythoner NewPythoner is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Bombay, India
Posts: 159 NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level)NewPythoner User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 43 m 45 sec
Reputation Power: 7
Send a message via Yahoo to NewPythoner
Code:
data = gradelist.read()

this is what u had... what r the contents of data...a list of list...as my example of gradeList...if not then thats where u got to start off!


Subha

Reply With Quote
  #15  
Old December 4th, 2004, 05:34 AM
Jackity84 Jackity84 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 36 Jackity84 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 48 m 23 sec
Reputation Power: 5
the data is just a list of ['astudent', 100, 'Very well done.']..with diff userids, grades, etc...

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Need help.. Reading datas..


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump