- Notifications
You must be signed in to change notification settings - Fork0
dhchenx/rsfile
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A Rust library to operate files or web pages easily and quickly
Thersfile
library include simplified operation functions for commonly used I/O, text files, csv files and web crawlers.
use rsfile::*;fnmain(){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 modelin 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);}
use rsfile::*;fnmain(){// 1. get HTML page information (including html string, title, meta, raw text, etc.)let page=fetch_html("https://www.rust-lang.org/");for kin page.keys(){println!("{}\t{:?}",k,page.get(k));};//2. get HTML page from a local path and obtain its HTML stringlet page=read_html_file("data/webpage.html");let html_opt=page.get("html");}
use rsfile::*;fnmain(){// read a linelet line=input_line();// read a line after a messagelet line=input_line_with_msg("Please input a line:");// read binarylet content =read_binary("data/test.txt");// write a text file for one timewrite_text_once("data/test2.txt","Hello, Rust!");// write a list of linesletmut lines:Vec<&str>=Vec::new(); lines.push("a"); lines.push("b");append_text("data/test2.txt",lines);}
Other available functions are:
- read_text()
- write_text()
- read_lines()
- append_text()
- write_text_once()
- write_lines()
- read_csv()
- read_csv_text()
- read_csv_with_error()
- write_csv_with_error()
- fetch_html()
- read_html_file()
- read_html_string()
- input()
- input_line()
- input_line_with_msg()
- print()
- read_binary()
More example codes can be foundhere.
MIT
About
A Rust library to operate files easily and quickly
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
No releases published
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.