1 个不稳定版本
0.1.1 | 2023 年 11 月 2 日 |
---|---|
0.1.0 |
|
#9 in #matches
12KB
116 代码行
csv_coincidence
在数据处理领域,CSV 文件常用于存储表格数据,能够高效地搜索和分析这些数据非常重要。这正是 csv_coincidence
库背后的动机,它是一个专注于使用可自定义的正则表达式在 CSV 文件中进行部分匹配搜索的库。此功能用于处理 CSV 文件并在文件中找到的文本字符串中搜索部分匹配。
功能
- 根据给定的正则表达式模式在 CSV 文件中找到部分匹配。
- 计算 CSV 文件中特定模式的出现次数。
- 合并与特定模式匹配的 CSV 文件记录,并替换这些匹配项。
用法
use csv_coincidence::find_partial_matches;
fn main() -> Result<(), Box<dyn Error>> {
let file_path = "example.csv"; // Replace with the path of your CSV file
let regex_pattern = r"^[A-Z][a-z]*"; // Replace with the regular expression
match find_partial_matches(file_path, regex_pattern) {
Ok(matches) => {
println!("Partial Matches:");
for match_str in matches {
println!("{}", match_str);
}
}
Err(err) => {
eprintln!("Error: {}", err);
}
}
Ok(())
}
use csv_coincidence::merge_coincidence;
fn main() -> Result<(), Box<dyn Error>> {
let file_path = "example.csv"; // Replace with the path of your CSV file
let regex_pattern = r"^[A-Z][a-z]*"; // Replace with the regular expression
match merge_coincidence(file_path, regex_pattern) {
Ok(merged_data) => println!("Merge concidences:\n{}", merged_data),
Err(e) => eprintln!("Error: {}", e),
}
}
许可证
本项目采用 MIT 许可证。
依赖项
~3.5–5MB
~73K SLoC