Refactor header extraction

This commit is contained in:
Sam Hedin 2020-03-27 22:24:22 +01:00
parent ec0bd20f29
commit 1b9c006696

View File

@ -44,22 +44,18 @@ pub fn count(
let stream = async_stream! { let stream = async_stream! {
let rows: Vec<Value> = input.values.collect().await; let rows: Vec<Value> = input.values.collect().await;
let mut entries = IndexMap::new(); let mut headers = vec![];
let headers: Value = rows[0].clone(); match &rows[0].value {
match &headers.value {
UntaggedValue::Row(d) => { UntaggedValue::Row(d) => {
entries = d.entries.clone(); for (_, v) in d.entries.iter() {
() headers.push(v.as_string().unwrap());
}
} }
_ => () _ => ()
} }
let mut heads = vec![];
for (k, v) in entries.iter() {
heads.push(v.as_string().unwrap());
}
let mut file = File::create("headout").unwrap(); let mut file = File::create("headout").unwrap();
write!(file, "args: {:#?}", heads); write!(file, "args: {:#?}", headers);
yield ReturnSuccess::value(UntaggedValue::int(rows.len()).into_value(name)) yield ReturnSuccess::value(UntaggedValue::int(rows.len()).into_value(name))
}; };