Package cs2110
Class Gradebook
java.lang.Object
cs2110.Gradebook
A collection of static methods for reading/writing gradebook tables in CSV format, transforming
their data, and calculating summary statistics.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
addSummaryColumns
(Seq<Seq<String>> table) Append "mean" and "standard deviation" columns to the end of the table `table`.static void
addSummaryRows
(Seq<Seq<String>> table) Append "mean" and "standard deviation" rows to the bottom of the table `table`.constructTable
(String filename) Read contents of a csv file and use this to construct a nested row-major sequence of strings.private static <T> boolean
isRectangular
(Seq<Seq<T>> table) Return whether each element of `table` has the same size.static void
A basic application to add summary statistics to a gradebook spreadsheet table.static double
Return the mean of the numerical entries of `seq`.static <T> void
Convert the contents of `table` into Simplified CSV format and write this to the file located at `filename`.static double
Return the sum of the n'th powers of all numerical entries of `seq`.roundEntries
(Seq<Seq<String>> table, int decimalPlaces) Rounds all numerical data within `table` to the specified number of decimal places.static double
Return the standard deviation of the numerical entries of `seq`.Return a new table that is the transpose of the original table.
-
Constructor Details
-
Method Details
-
constructTable
Read contents of a csv file and use this to construct a nested row-major sequence of strings. Throws an IOException if `filename` cannot be accessed or read from.- Throws:
IOException
-
outputCSV
Convert the contents of `table` into Simplified CSV format and write this to the file located at `filename`. Throws an IOException if `filename` cannot be accessed or written to.- Throws:
IOException
-
isRectangular
Return whether each element of `table` has the same size. -
transpose
Return a new table that is the transpose of the original table. That is, the rows of the original table become the columns of the new table (and vice versa), and the orders of the entries in these rows / columns remains the same. Requires `original` is rectangular. -
powerSum
Return the sum of the n'th powers of all numerical entries of `seq`. A numerical entry is any entry that can be successfully parsed to a double by Double.parseDouble(). -
mean
Return the mean of the numerical entries of `seq`. Returns NaN (aka 0.0/0.0) if `seq` does not contain any numerical entries. -
stdDev
Return the standard deviation of the numerical entries of `seq`. Returns NaN (aka 0.0/0.0) if `seq` does not contain any numerical entries. -
addSummaryColumns
Append "mean" and "standard deviation" columns to the end of the table `table`. The first row of the table (the column "headers") has "mean" and "standard deviation" appended (in that order). In subsequent rows, the string representations of the mean and standard deviation (in that order) of the numerical entries are appended. All numbers are represented with full precision. Requires that `table` is rectangular with at least one row and that no rows alias one another. -
addSummaryRows
Append "mean" and "standard deviation" rows to the bottom of the table `table`. The first entries of these rows are "mean" and "standard deviation" (respectively). The subsequent entries are the mean and standard deviation (respectively) of the numerical entries in that column. All numbers are represented with full precision. Requires that `table` is rectangular with at least one column (implying at least one row). -
roundEntries
Rounds all numerical data within `table` to the specified number of decimal places. -
main
A basic application to add summary statistics to a gradebook spreadsheet table. Takes in two program arguments: the filepath of the input csv and the filepath for the output csv.- Throws:
IOException
-