Note that there are some explanatory texts on larger screens.

plurals
  1. POHaving problems creating kmls with python
    text
    copied!<p>I am creating kml files using python and the simplekml creator. For some reason it creates two kml files and will not create the third. Data seems fine to me. Here is the code:</p> <pre><code>times=open("E:\\Python\Copyofresttable.csv","r") import time import csv import simplekml from time import strftime, localtime dayoftheweekvariable = strftime("%A", localtime()) print dayoftheweekvariable kml = simplekml.Kml() if dayoftheweekvariable == "Monday": for line in times: a = line.split(',') if a[2] == "Monday": print a[5] if dayoftheweekvariable == "Tuesday": for line in times: a = line.split(',') if a[2] == "Tuesday": print a[5] if dayoftheweekvariable == "Wednesday": for line in times: a = line.split(',') if a[1]== "Iron Hill" and a[2] =="Wednesday": kml.newpoint(name="Iron Hill", coords=[(-75.605507,39.960504)], description=a[5]) kml.save("pythonmap.kml") print "Creating KML" if a[1]== "Side Bar and Resturant" and a[2] =="Wednesday": kml.newpoint(name="Side Bar and Resturant", coords=[(-75.604805,39.960591)], description=a[5]) kml.save("pythonmap.kml") print "Creating KML" if a[1]== "Barnaby's" and a[2] =="Wednesday": kml.newpoint(name="Barnaby's", coords=[(-75.604049,39.959488)], description=a[5]) kml.save("pythonmap.kml") print "Creating KML" </code></pre> <p>obviously testing this out on Wednesday night...As for the last three if statements, no matter what order i put them in, it will create a kml for Iron Hill and Barnaby's but not side bar. this is the result it returns:</p> <pre><code>Wednesday Creating KML Creating KML Traceback (most recent call last): File "C:/Users/75IV740906/Desktop/py117", line 26, in &lt;module&gt; if a[1]== "Iron Hill" and a[2] =="Wednesday": IndexError: list index out of range </code></pre> <p>the error message calls out what ever if statement is on top. Im stumped. Hope my question makes sense(why is it giving me this error message and only creating two kmls no matter what order the if statements are in)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload