Page 1 of 3 123 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    36
    Rep Power
    10

    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?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    36
    Rep Power
    10
    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...
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    36
    Rep Power
    10
    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
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Location
    Bombay, India
    Posts
    159
    Rep Power
    12
    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
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    36
    Rep Power
    10
    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?
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Location
    Bombay, India
    Posts
    159
    Rep Power
    12
    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
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    36
    Rep Power
    10
    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
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Location
    Bombay, India
    Posts
    159
    Rep Power
    12
    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
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    36
    Rep Power
    10
    hey yea, the 2nd code that you wrote is what the teacher gave us as example.. so im still lost.. dunno what to do.
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    36
    Rep Power
    10
    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 ~!!
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Location
    Bombay, India
    Posts
    159
    Rep Power
    12
    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
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    36
    Rep Power
    10
    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?
  24. #13
  25. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    36
    Rep Power
    10
    k here's what the form looks like

    http://cmpt165.cs.sfu.ca/~jju/as4.html
  26. #14
  27. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Location
    Bombay, India
    Posts
    159
    Rep Power
    12
    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
  28. #15
  29. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    36
    Rep Power
    10
    the data is just a list of ['astudent', 100, 'Very well done.']..with diff userids, grades, etc...
Page 1 of 3 123 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo