#1
  1. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2004
    Location
    There where the rabbits jump
    Posts
    556
    Rep Power
    11

    read(),readline(),readlines()???


    Okay I am making a program that uses alot of IO transfer

    At the moment I need to read 3 lines of data to be read by the program at a time.

    I have no clue how to do it.

    Please help me
  2. #2
  3. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    154
    Can you post an example?
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2004
    Location
    There where the rabbits jump
    Posts
    556
    Rep Power
    11
    Originally Posted by †Yegg†
    Can you post an example?
    Okay heres the example

    Only the start_up_definition matters ant the Ids filw which is equal to a txt.

    I need to read 3 or 2 depending on the situation.
    Attached Files
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2004
    Location
    London, England
    Posts
    1,585
    Rep Power
    1373
    Firstly I suggest that with files that small you cut and past the text into your post, rather than attach it as a zip. Currently the reader has to download the file, open it with a zip program, and then open the file in a viewer to read it. Many of the people who would otherwise offer advice may decide it is too much hassle and go on to the next post. If you do paste it into your post, make sure you surround it with [ code ] [ /code ] tags (minus the spaces) to preserve the indentation and to mark it out as code.

    The file object returned by open() can be read in several ways. the readline() method will do what you want, but you do not want to pass it a parameter. In your example code you call it with server.readline(1) which reads at most one character from the file. Just call it with server.readline() and it will read the entire line up to and including the linefeed at the end.

    Dave - The Developers' Coach
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2004
    Location
    There where the rabbits jump
    Posts
    556
    Rep Power
    11
    Okay Thanks so readline() will read one line at a time until I say to read another line

IMN logo majestic logo threadwatch logo seochat tools logo