#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    2
    Rep Power
    0

    How to read 2D points from a .txt file!!


    I have a gtfs file which contains data about the bus stops and stations. I need to write python code to read in 2D points locations!

    please help me!
    thanks in advance!
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Location
    Tewksbury, MA
    Posts
    36
    Rep Power
    2
    They're comma separated values in your file so it should be easy to pull out what you need and generate the list. What part are you having problems with? Can you read the lines from your file?

    This looks like homework so you should at least post your attempt. Show us where you're stuck and we can work through it.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    2
    Rep Power
    0
    Originally Posted by Marbelous
    They're comma separated values in your file so it should be easy to pull out what you need and generate the list. What part are you having problems with? Can you read the lines from your file?

    This looks like homework so you should at least post your attempt. Show us where you're stuck and we can work through it.
    yea.. I have managed to read the lines..
    I'm at stuck where to create tuples from lines and to retrieve only the attributes I need( lat, long , name, etc)
  6. #4
  7. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Location
    Tewksbury, MA
    Posts
    36
    Rep Power
    2
    Well, you're using the readlines method and that will create a list of each line in your file for you (delimits on the newlines). So just iterate through that list and use your split function on the comma. Then you can index the items you want and create your tuple...

IMN logo majestic logo threadwatch logo seochat tools logo