Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Change</p> <pre><code>times=open("E:\\Python\Copyofresttable.csv","r") </code></pre> <p>to:</p> <pre><code>times=open("E:\\Python\Copyofresttable.csv","r").read() </code></pre> <p>in your first line and add a</p> <pre><code>print('#Times: {0}'.format(len(times.split()))) </code></pre> <p>to make sure you have enough lines...</p> <p><strong>Update</strong>:</p> <p>You traceback (in comment) shows that your (1st?!) <code>dayoftheweek</code> seems to be a wednesday, that's why your 1st two ifs are ignored. Then it seems like your list <code>a</code> doesn't have nough entries.</p> <p>You may check that assumption with a <code>print("# a: {0}".format(len(a)))</code></p> <p>So if you have less then 3 entries <code>a[2]==</code> must fail because the <code>list index out of range</code> ;-)</p> <p>Ahh, i didn't read your question properly at first. And it makes more sense that way, if every 1st if-statement is throwing an exception....</p> <p><strong>Update 2:</strong> Btw: You should rearange your <code>for line in times:</code> loops to a less redundant way, like:</p> <pre><code>lines=open("E:\\Python\Copyofresttable.csv","r").readlines() ... for line in lines: a = line.split(',') if a[2] == "Monday" == dayoftheweek: ... elif a[2] == "Tuesday" == dayoftheweek: ... elif a[1]== "Iron Hill" and a[2] =="Wednesday" == dayoftheweek: ... </code></pre> <p><strong>Update 3:</strong></p> <p>You could "cheat" a little if ommiting some lines, by doing something like:</p> <pre><code>a = line.split(',') if len(a) &lt; 6: continue # ignores the rest of the loop and jumps stright to the next iteration </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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