it's 1am, I wanna die

but I am done
This commit is contained in:
René Fuhry 2023-06-01 01:02:26 +02:00 committed by GitHub
parent a70463e14f
commit 57e89300ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,6 @@
#[allow(unused_imports)] #[allow(unused_imports)]
use std::{fs::File, io::Read}; use std::{fs::File, io::Read};
use csv::ReaderBuilder;
pub fn fill_with_random(size: usize) -> Vec<Vec<usize>> { pub fn fill_with_random(size: usize) -> Vec<Vec<usize>> {
let mut matrix: Vec<Vec<usize>> = vec![]; let mut matrix: Vec<Vec<usize>> = vec![];
@ -43,24 +44,23 @@ pub fn show(matrix: &Vec<Vec<usize>>) {
} }
pub fn read_csv() -> Vec<Vec<usize>> { pub fn read_csv() -> Vec<Vec<usize>> {
let matrix: Vec<Vec<usize>> = vec![ let mut matrix: Vec<Vec<usize>> = vec![];
vec![0, 0, 1, 1, 0], let dir: String = String::from("/home/rene/projects/Java/graphprogram/csv/");
vec![0, 0, 1, 1, 0], let file_path: String = dir + &String::from("art-brck.csv");
vec![1, 1, 0, 1, 0], let mut csv = ReaderBuilder::new()
vec![1, 1, 1, 0, 1], .has_headers(false)
vec![0, 0, 0, 1, 0] .delimiter(b';')
]; .from_path(file_path)
/* .unwrap();
let mut csv = File::open("").unwrap();
let mut content = String::new();
csv.read_to_string(&mut content).unwrap();
println!("{content}");
now I need regex to filter and put everything into a two dim vector let mut index = 0;
for result in csv.records() {
See https://crates.io/crates/regex for regex crate let record = result.unwrap();
See https://docs.rs/regex/1.8.3/regex/struct.Regex.html for regex crate documentation matrix.push(vec![]);
See https://doc.rust-lang.org/std/fs/struct.File.html for file ops for field in record.iter() {
*/ matrix[index].push(field.parse().unwrap());
}
index += 1;
}
matrix matrix
} }