Forums

CSV End of Line

Hi everybody.

I am having a trouble, how can I indicate "end of data or en of document" in a CSV format? I have a for cycle and I an getting a error next to the last line, the error says "List index out of range ".

I have tried \n , \r\n, LF, 0x0a, no one works.

Persona;Estado_civil;Estado;Ocupacion;Edad Petronilo,Soltero,Aragua,Ingeniero y Medico,31 Juan,Casado,Carabobo,Arquitecto,32 Larissa,Soltero,Lara,Arquitecto,43 Carmen,Soltero,Cojedes,Contadora y Abogado,21 Trobilgo,Casado,Cojedes,Ingeniero,56 Pedro,Soltero,Lara,Abogado E Ingeniero,43 Miguel,Soltero,Carabobo,Abogado,31

What can I do after "... Abogado, 31"

Thanks in advance.

Normally you'd just iterate over the lines of the file, and Python would tell you when you've reached the end. What code are you using to load and parse the file?

You might also want to look into Python's built-in csv module -- it will do a lot of the heavy lifting for you.