A Rust library to operate files or web pages easily and quickly
```rust fn test_rsfile(){ use rsfile;
// read a csv file and load a list of HashMap models where you can get value by key.
let result=rsfile::read_csv_simple("data/test.csv");
for model in result{
println!("RECORD: {:?}",model);
}
// save a csv file by using a list of HashMap models where you can get value by key.
let list_model=rsfile::read_csv("data/test.csv");
let flag=rsfile::write_csv("data/test1.csv",list_model);
println!("{}",flag);
} ```
```rust
mod tests { use rsfile::*; # [test] fn testgethtml(){ // obtain html page let page=fetchhtml("https://www.rust-lang.org/"); for k in page.keys(){ println!("{}\t{:?}",k,page.get(k)); }; // get html tag content let htmlstr=match page.get("html"){ Some(t)=>t.tostring(), None=>{String::from("")} }; //write to a html file path let hh=&htmlstr[..]; let flag=writetext("data/webpage.html",hh); } #[test] fn testreadhtml(){ // read html file from local path let page=readhtmlfile("data/webpage.html"); let htmlopt=page.get("html"); // get html strings let htmlstr=match htmlopt { Some(t)=>t.tostring(), None=>String::from("").tostring() }; let page1=readhtmlstring(htmlstr); // let page1=readhtmlstring(getrefstringstr(htmlopt)); showdict(page); } } ```
Other available functions are:
More example codes can be found here.
MIT