[Python] Reading a file with inconsistent number of columns per row

Discussão em 'Python' iniciado por Stack, Julho 8, 2025.

  1. Stack

    Stack Membro Participativo

    The file I have is looong (160k lines). Most of it is pretty consistent, but some lines are like this:

    ID name val1 val2 val3 X Y Z
    ID name X Y Z
    ID name val1 val2 val3 X Y Z


    And it's random, so this makes it really difficult to read it properly.

    Pandas returns 8 columns, but in the wrong order:

    ID name val1 val2 val3 X Y Z
    ID name X Y Z Nan Nan Nan
    ID name val1 val2 val3 X Y Z

    Continue reading...

Compartilhe esta Página