-
-
Save birkenfeld/fb4ec61ec70f781b93f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::io::{self, BufReader, BufWriter}; | |
use std::io::prelude::*; | |
use std::fs::File; | |
fn main() { | |
let reader = io::stdin(); | |
for line in reader.lock().lines() { | |
let path = line.unwrap(); | |
let tmp_filename = path.clone() + "Leitner_2009R2_CompleteExport.txt"; | |
let f = File::open(tmp_filename).unwrap(); | |
let f = BufReader::new(f); | |
let mut new_f = None; | |
for line2 in f.lines() { | |
let mut curr_line = line2.unwrap_or("".into()); | |
println!("{}", curr_line); | |
if curr_line.len() > 6 && &curr_line[..6] == "OBJECT" { | |
let new_name = curr_line.replace("/", "_"); | |
let tmp_curr_filename = path.clone() + &new_name + ".txt"; | |
let curr_file = File::create(tmp_curr_filename).unwrap(); | |
new_f = Some(BufWriter::new(curr_file)); | |
} | |
if let Some(nf) = new_f.as_mut() { | |
curr_line.push('\n'); | |
nf.write(curr_line.as_bytes()).unwrap(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment