[Python] Python csv get original raw data line

Discussão em 'Python' iniciado por Stack, Março 15, 2025.

  1. Stack

    Stack Membro Participativo

    In python it is easy to read and parse a csv file and process line-by-line:

    reader = csv.reader(open("my_csv_file.csv"))
    for row in reader:
    # row is an array or dict
    parsed_data = my_data_parser(row)



    where my_data_parser is my own piece of logic that takes input data, parses and does logic.

    If my parser fails, I would like to log the entire original line of csv file, but it seems that from the csv reader i have no more access to it.

    Is it possible to retrieve the original raw line data?

    Continue reading...

Compartilhe esta Página