Below is a Python script that reads a CSV file, displays its content, and writes it to another text file.
import csv
def read_and_display(input_file):
with open(input_file, 'r') as file:
reader = csv.reader(file)
for row in reader:
print(row)
def write_to_file(input_file, output_file):
with open(input_file, 'r') as infile, open(output_file, 'w', newline='') as outfile:
reader = csv.reader(infile)
writer = csv.writer(outfile)
for row in reader:
writer.writerow(row)
if __name__ == "__main__":
# Replace 'input.csv' with the path to your input file
input_file_path = 'input.csv'
# Replace 'output.csv' with the path to your output file
output_file_path = 'output.csv'