New to Programming: TypeError: coercing to Unicode: need string or buffer, list found

Chris Angelico rosuav at gmail.com
Fri Apr 3 02:12:12 CEST 2015


On Fri, Apr 3, 2015 at 11:03 AM, Dennis Lee Bieber
<wlfraed at ix.netcom.com> wrote:
>>o IF all the contents in the file have the same length (let's assume line length)
>>
>>o THEN the file should be moved to a "success" folder and a text file written indicating the total number of records/lines/words processed
>>
>>o IF the file is empty OR the contents are not all of the same length
>>
>>o THEN the file should be moved to a "failure" folder and a text file written indicating the cause for failure (for example: Empty file or line 100 was not the same length as the rest).
>>
>         You still haven't defined how you determine the "correct length" of the
> record. What if the first line is 79 characters, and all the others are 80
> characters? Do you report ALL lines EXCEPT the first as being the wrong
> length, when really it is the first line that is wrong?

Relatively immaterial here; in the first place, line length is just a
placeholder (my guess is it's more likely to be something like "CSV
files with the same number of cells on each row", or something), and
in the second place, the lines aren't the failures - if there's a
mismatch, the entire file is deemed wrong. It doesn't matter whether
it's the first line or the other lines, the file is dead.

ChrisA



More information about the Python-list mailing list