Python - Read a CSV file through csv module


Python - Read a CSV file through csv module

CODE
import csv filename = "input.csv" fields = [] rows = [] with open(filename, 'r') as csvfile: csvreader = csv.reader(csvfile) fields = next(csvreader) for row in csvreader: rows.append(row) for field in fields: print(field + "\t", end="") print("") for row in rows: for col in row: print(col + "\t", end=""), print("") """ INPUT FILE: input.csv Name,Place Pedro,London Rob,Boston Ulrich,Denver OUTPUT Name Place Pedro London Rob Boston Ulrich Denver """

Comments