[Tutor] a quick Q: how to use for loop to read a series of files with .doc end

lina lina.lastname at gmail.com
Sat Oct 8 09:28:06 CEST 2011


On Sat, Oct 8, 2011 at 2:50 PM, Andreas Perstinger <
andreas.perstinger at gmx.net> wrote:

> On 2011-10-08 08:25, lina wrote:
>
>>  Still have a reading "multiple" files issue:
>>>
>>>>
>>>>  Traceback (most recent call last):
>>>>   File "counter-vertically-WORKING.****py", line 26, in<module>
>>>>
>>>>     results[ch][col]+=1
>>>>  IndexError: list index out of range
>>>>
>>>>  only one file ss_1.xpm was processed and wrote file, for the rest
>>>>  ss_2.xpm,
>>>>  ss_3.xpm and following keep intact,
>>>>
>>>>  any suggestions?
>>>>
>>>
>> https://docs.google.com/leaf?**id=**0B93SVRfpVVg3MjIxZGI5YWQtN2NiY**
>> y00MWFkLWE0ZTctNjExNGJiNjYzYjQ**w&hl=en_GB<https://docs.google.com/leaf?id=0B93SVRfpVVg3MjIxZGI5YWQtN2NiYy00MWFkLWE0ZTctNjExNGJiNjYzYjQw&hl=en_GB>
>>
>> https://docs.google.com/leaf?**id=**0B93SVRfpVVg3YjQ1ZWRkMjUtNmZhY**
>> S00MTA4LTg3YTktY2JjYzEyMDU5OTI**2&hl=en_GB<https://docs.google.com/leaf?id=0B93SVRfpVVg3YjQ1ZWRkMjUtNmZhYS00MTA4LTg3YTktY2JjYzEyMDU5OTI2&hl=en_GB>
>>
>> https://docs.google.com/leaf?**id=**0B93SVRfpVVg3YjQ1ZWRkMjUtNmZhY**
>> S00MTA4LTg3YTktY2JjYzEyMDU5OTI**2&hl=en_US<https://docs.google.com/leaf?id=0B93SVRfpVVg3YjQ1ZWRkMjUtNmZhYS00MTA4LTg3YTktY2JjYzEyMDU5OTI2&hl=en_US>
>>
>> you may rename ss_1.xpm to the ss_2 or 3, keep them the same is okay, just
>> different names.
>>
>
> Ok, I just ran your script with this files and don't get an error. Except
> some stylistic issues the code looks fine. The resulting txt-files still
> have the problem with the leading '[' and trailing ']' but I've already
> suggested a solution earlier today.
>
> Do you still get an error?


I figured it out, my mistake,

the following files from ss_2.xpm to ss_10.xpm has one more line than
ss_1.xpm

so after changed
LINESTOSKIP=23
to 24

it works.

before the ss_1.xpm was taking as the trial and finished, the last 9 was
generated with script, so there was a very minor differences.

Thanks for your help,

Best,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111008/a7ab34b7/attachment.html>


More information about the Tutor mailing list