0

My question is not a duplicate because it is using turtle graphics. So I have to write a program that reads a csv file which contains earthquake data, it then takes only the latitude and longitude from the file and map it to the turtle screen in Python 3.

This is the CSV file, please visit http://textuploader.com/gayg

My program:

import turtle
def drawQuakes():
 filename = input("Please enter the quake file: ")
 readfile = open(filename, "r")
 readlines = readfile.read()

 start = readlines.find("type")
 g = readlines[start]
 Type = g.split(",")
 tracy = turtle.Turtle()
 tracy.up()
 for points in Type:
     print(points)
     x = float(points[1])
     y = float(points[2])
     tracy.goto(x,y)
     tracy.write(".")
drawQuakes()

I know this program is fairly easy, but I keep getting this error:

x = float(Type[1])IndexError: list index out of range
unor
  • 92,415
  • 26
  • 211
  • 360
polish
  • 1
  • I suspect you and malcolm are in the same class. Otherwise, it's a little baffling that he asked effectively the same question an hour ago—with different code, but the same variable names, and the exact same mistakes. If many people in your class were confused in the exact same way by the assignment, you may want to bring it up with your teacher. – abarnert May 05 '15 at 02:29
  • This is a different question, I believe. I am printing the coordinates to the turtle screen. – polish May 05 '15 at 02:32
  • But you're making the exact same mistakes he is, so the solution is the same. Fitting it into the rest of your code should be trivial (and if it isn't, you should both have created a [minimal, complete, verifiable example](http://stackoverflow.com/help/mcve) that left out all the non-trivial stuff that isn't related to the problem). – abarnert May 05 '15 at 02:34
  • Although actually, I see that you're using `read` instead of `readlines`, which does mean you have somewhat different problems. I also see that your exception doesn't come from any of the actual lines of code in your example, which means you're not even showing us the same code you're running… – abarnert May 05 '15 at 02:35
  • help me! ......................... – polish May 05 '15 at 02:50
  • If you edit the question to show the actual code and the actual exception (with traceback) generated by that code, and to explain why the answer to the other question didn't help you, it'll probably be reopened. – abarnert May 05 '15 at 02:50

0 Answers0