This commit is contained in:
2026-05-17 20:15:09 +03:00
commit 3fc472a5bc
8 changed files with 3764 additions and 0 deletions

1
.envrc Normal file
View File

@@ -0,0 +1 @@
use nix

4
.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
.direnv/
target/
.~lock*
*.csv

0
.zed/tasks.json Normal file
View File

3694
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

9
Cargo.toml Normal file
View 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
View 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
View 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

Binary file not shown.