Skip to content

Commit

Permalink
update: clickhouse 的情况下,获取 factor.csv 后自动删除
Browse files Browse the repository at this point in the history
  • Loading branch information
zjp-CN committed Feb 18, 2023
1 parent ea5b60c commit 8fa20a0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions rustdx-cmd/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,14 @@ pub fn previous_csv_table(path: &Option<std::path::PathBuf>, table: &str) -> Pre

/// 读取前收盘价(前 factor )数据
pub fn previous_csv(p: impl AsRef<Path>) -> Previous {
Ok(csv::Reader::from_reader(File::open(p)?)
let path = p.as_ref();
let prev = csv::Reader::from_reader(File::open(path)?)
.deserialize::<Factor>()
.filter_map(|f| f.ok())
.map(|f| (f.code.parse().unwrap(), f))
.collect())
.collect();
fs::remove_file(path)?;
Ok(prev)
}

/// 获取当前最新 factor
Expand Down

0 comments on commit 8fa20a0

Please sign in to comment.