yeah
This commit is contained in:
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
.direnv/
|
||||||
|
target/
|
||||||
|
.~lock*
|
||||||
|
*.csv
|
||||||
0
.zed/tasks.json
Normal file
0
.zed/tasks.json
Normal file
3694
Cargo.lock
generated
Normal file
3694
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
9
Cargo.toml
Normal file
9
Cargo.toml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
[package]
|
||||||
|
name = "canvas_grades"
|
||||||
|
version = "0.0.1"
|
||||||
|
authors = [ "Aly Sewelam <linlysmolworthy@gmail.com>" ]
|
||||||
|
edition = "2024"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
polars = {version = "0.53.0", features = ["csv", "lazy"] }
|
||||||
|
|
||||||
14
shell.nix
Normal file
14
shell.nix
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{ pkgs ? import <nixpkgs> {} }:
|
||||||
|
|
||||||
|
pkgs.mkShell {
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
rustup
|
||||||
|
pkg-config
|
||||||
|
openssl
|
||||||
|
];
|
||||||
|
|
||||||
|
shellHook = ''
|
||||||
|
rustup toolchain install stable
|
||||||
|
rustup default stable
|
||||||
|
'';
|
||||||
|
}
|
||||||
42
src/main.rs
Normal file
42
src/main.rs
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
use polars::prelude::*;
|
||||||
|
|
||||||
|
fn main() -> Result<(), PolarsError> {
|
||||||
|
// Read CSVs
|
||||||
|
let students = CsvReadOptions::default()
|
||||||
|
.with_has_header(true)
|
||||||
|
.try_into_reader_with_file_path(Some("final_students.csv".into()))?
|
||||||
|
.finish()?;
|
||||||
|
|
||||||
|
let grades = CsvReadOptions::default()
|
||||||
|
.with_has_header(true)
|
||||||
|
.try_into_reader_with_file_path(Some("final_grades.csv".into()))?
|
||||||
|
.finish()?;
|
||||||
|
|
||||||
|
// Join on "email", keep id + lab columns
|
||||||
|
let result = students
|
||||||
|
.join(
|
||||||
|
&grades,
|
||||||
|
["email"],
|
||||||
|
["email"],
|
||||||
|
JoinArgs::new(JoinType::Inner),
|
||||||
|
None,
|
||||||
|
)?
|
||||||
|
.lazy()
|
||||||
|
.with_column(((col("Activity 1") + col("Activity 2")) / lit(2.0)).alias("Activities"))
|
||||||
|
.collect()?
|
||||||
|
.select([
|
||||||
|
"ID",
|
||||||
|
"Course Assessment",
|
||||||
|
"Activities",
|
||||||
|
"Knowledge Checks",
|
||||||
|
])?;
|
||||||
|
|
||||||
|
println!("{}", result);
|
||||||
|
|
||||||
|
// Write output
|
||||||
|
let mut file = std::fs::File::create("output2.csv").unwrap();
|
||||||
|
CsvWriter::new(&mut file).finish(&mut result.clone())?;
|
||||||
|
|
||||||
|
println!("Written to output.csv");
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
BIN
students2.xlsx
Normal file
BIN
students2.xlsx
Normal file
Binary file not shown.
Reference in New Issue
Block a user