lance bermudez
April 30th, 2015, 06:20 AM
Ok what i want to do is take the info out the print function and put it into another csv file.
python3 script
import csv
with open('C:/Users/lance/Videos/11001.csv') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
#I want this print fieldnames written to another file with the data.
print('\n',
'S, Last name, First Name, Grade\n'.upper(),
row['OrgDefinedId'],
row['Last Name'],
row['First Name'],
'{:.2f}'.format(float(row['Calculated Final Grade Numerator'])))#this line has to keep its formatting
I'm stuck I do not know how to proceed. Was thinking of something like this
import csv
import operator
with open('C:/Users/lance/Videos/11001.csv') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
snumber = row['OrgDefinedId']
last = row['Last Name']
first = row['First Name']
grade = '{:.2f}'.format(float(row['Calculated Final Grade Numerator']))
print(snumber)
csvfile = open('eggs.txt','w')
csvfile.write (snumber)
csvfile.write (',')
But this does not write out all the snumber that is seen in the print just the first line.
python3 script
import csv
with open('C:/Users/lance/Videos/11001.csv') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
#I want this print fieldnames written to another file with the data.
print('\n',
'S, Last name, First Name, Grade\n'.upper(),
row['OrgDefinedId'],
row['Last Name'],
row['First Name'],
'{:.2f}'.format(float(row['Calculated Final Grade Numerator'])))#this line has to keep its formatting
I'm stuck I do not know how to proceed. Was thinking of something like this
import csv
import operator
with open('C:/Users/lance/Videos/11001.csv') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
snumber = row['OrgDefinedId']
last = row['Last Name']
first = row['First Name']
grade = '{:.2f}'.format(float(row['Calculated Final Grade Numerator']))
print(snumber)
csvfile = open('eggs.txt','w')
csvfile.write (snumber)
csvfile.write (',')
But this does not write out all the snumber that is seen in the print just the first line.