how to write into a CSV file with a Python Programming? So, Here I have given Python Code and CSV file which I was used in Tutorial. Python Code: import csv with open("data.txt", "r") as dataFile: dataFileReader = csv.reader(dataFile) dataList = [] for row in dataFileReader: if len (row) != 0: dataList = dataList + [row] dataFile.close() print(dataList) name = input("Enter name: ") secondName = input("Enter secondName: ") value1 = input("value1: ") value2 = input("value2: ") value3 = input("value3: ") with open("data.txt", "a") as dataFile: dataFileWriter = csv.writer(dataFile) dataFileWriter.writerow([name, secondName, value1, value2, value3]) dataFile.close() CSV File : ABC, XYZ, 1, 2, 3 PQR, WXY, 4, 5, 6 DEF, JKL, 7, 8, 9 This Python code is made for a view, imports, and write the comma separated files in python app. Also with this code user can r...
It's a blog for learn and know about one of the best web tools and tricks of web programming in the easiest way. So, If you want to stay updated with the technology follow the page now!!