I am trying to calculate various numbers (mean, median, etc.) from a csv dataset and then write this information into a txt file. For reference, my dataset is SAT scores, so the sample I have below is code for SAT reading scores. Right now I am trying to use an array, and have this:
a=[1,2,3,4,5,6]
b=[rmean, rmed, rmax, rmin, rsd, rvar]
output=open("output.txt", "w")
output.write("For the variable READ:\n The mean is")
for i in range(len(a)):
output.write(" %i %5.2f\n" % (a[i], b[i]))
output.close()
I want my txt file to look something like:
For the variable READ, the mean is [value of rmean variable], the median is [value of rmed variable], etc.
How do I manipulate the array to do that, as opposed to the matrix view it's currently outputting? And additionally, is there any way to avoid having to use the numbers in array a or to avoid having them appear in my txt file output? Thank you!