For some reason, I can't get the csv reader to read any lines. I'm using IDLE to edit the text and running Python 3.4. The file is opening, and I can get plain text from the file. I'm trying to loop through the csv using a reader so I can edit certain items of certain columns. The program is organizing people in a file into two separate files. Here is my code as it stands:
# Desc: File used to split single data file into two separate files, based
# on whether the person has been terminated from the program or not.
#
# Written in Python 3.4
# Last updated: 2/26/2017
import csv
datafile = "mow-data.csv" # the raw data
fileCurrent = "mow-data-current.csv" # data of people still in the program
fileTerminated = "mow-data-terminated.csv" # data of people no longer in the program
# Open read and write files and create csv reader and writer
readFile = open(datafile, 'r')
readFileText = readFile.read()
reader = csv.reader(readFile, delimiter=',')
writeFileCurrent = open(fileCurrent, 'w')
writeFileTerminated = open(fileTerminated, 'w')
writerCurr = csv.writer(writeFileCurrent, delimiter=',')
writerTerm = csv.writer(writeFileTerminated, delimiter=',')
# Loop through every row in csv
for row in reader:
writerCurr.writerow(row) ### testing
print("test") ### testing
# Closing the files
readFile.close()
writeFileCurrent.close()
writeFileTerminated.close()
### END OF FILE
For some reason, the for loop doesn't seem to be doing anything. Any help? Also, here is a bit of the csv file I'm using with a lot of personal info changed:
address1,address2,city,state,zipcode,date1,column7,date2,level,date3,date4,reason,date5,data2
1234 FAKE ST.,,NOWHERE,KY,48880,18-Feb-12,CLIENT,1-Sep-53,,1-Oct-93,6-Jul-04,DE,2-Dec-98,Y
4908 NOTREAL AVE,,SOMEWHERE,MO,46212,21-Jun-21,CLIENT,10-Nov-97,,1-May-92,3-Jan-07,DE,1-Dec-78,Y