Commit 0d4b52b8 authored by richardARPANET's avatar richardARPANET

wip

parent b661b88a
/target
**/*.rs.bk
\ No newline at end of file
**/*.rs.bk
*.csv
.vscode
This diff is collapsed.
[package]
name = "csv-merge"
description = "A cli tool for merging CSV files"
version = "0.1.0"
authors = ["Richard O'Dwyer <richard@richard.do>"]
edition = "2018"
license = "Apache-2.0"
repository = "https://github.com/richardARPANET/csv-merge"
readme = "README.md"
keywords = ["cli", "csv", "merge"]
[dependencies]
csv = "1"
# The development profile, used for `cargo build`
[profile.dev]
opt-level = 0 # Controls the --opt-level the compiler builds with
debug = true # Controls whether the compiler passes `-g`
# The release profile, used for `cargo build --release`
[profile.release]
opt-level = 3
debug = false
[dev-dependencies]
assert_cli = "0.6.3"
# csv-merge
## Example usage
```bash
cargo run input.csv input2.csv > output_merged.csv
```
header,header2
a,123
hello,456
bob,
#![feature(intrinsics)]
#![feature(core_intrinsics)]
// use std::intrinsics;
//! `csv-merge` is a CLI tool for merging CSV files.
//!
extern crate csv;
use core::intrinsics;
use std::error::Error;
use std::io;
use std::env;
use std::path::Path;
fn main() {
let stuff2 = "Stuff";
unsafe {
let stuff = "Stuff";
intrinsics::breakpoint();
fn main() -> Result<(), Box<Error>> {
let args:Vec<String> = env::args().collect();
let csv_paths = &args[1..];
let mut headers_written = false;
let mut writer = csv::Writer::from_writer(io::stdout());
for csv_path in csv_paths
{
if Path::new(csv_path).exists() == false {
let msg = format!("{} does not exist", csv_path);
return Err(Box::from(msg));
}
let mut reader = csv::Reader::from_path(&csv_path)?;
if headers_written == false {
writer.write_record(reader.headers()?)?;
headers_written = true;
}
for record in reader.records() {
writer.write_record(&record?)?;
}
}
writer.flush()?;
return Ok(());
}
#[cfg(test)]
mod tests {
use assert_cli;
#[test]
fn test_outputs_csv() {
let expected_output = "\
header,header2\n\
a,123\n\
hello,456\n\
bob,\n\
2-a,2-123\n\
2-hello,2-456\n\
2-bob,";
let cmd = &[
"cargo", "run", "src/test_data/1.csv", "src/test_data/2.csv"
];
assert_cli::Assert::command(cmd)
.stdout().is(expected_output)
.unwrap();
}
// pub unsafe extern "rust-intrinsic" fn breakpoint();
}
// // use std::intrinsics::breakpoint;
// use std::env;
// // use std::error::Error;
// use std::io;
// // use std::process;
// extern crate csv;
// fn main() {
// println!("Hello, world!");
// let args:Vec<String> = env::args().collect();
// let csv_paths = &args[1..];
// println!("{:?}", csv_paths);
// println!("Loading csv.");
// let mut rdr = csv::Reader::from_reader(io::stdin());
// breakpoint!();
// for result in rdr.records() {
// println!("{:?}", result);
// }
// }
Remove this line from ~/.bashrc AND ~/.bash_profile
```
export PATH=$PATH:/home/$USER/chomper/bin
```
sudo pkill -f mitmdump
Remove
```
rm -rf ~/chomper
```
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment