Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- def appendCol(fName, colName, values):
- with open(fName) as fn:
- lines = fn.read().splitlines()
- with open(fName, "w") as fnw:
- print(lines[0] + ", " + colName, file=fnw)
- for x in range(1, len(lines)):
- if x <= len(values):
- print(lines[x] + ", " + str(values[x-1]), file=fnw)
- else:
- print(lines[x], file=fnw)
- appendCol("Q4.txt","Grade",[20, 60, 75, 15])
Advertisement
Add Comment
Please, Sign In to add comment