mirror of
https://github.com/nushell/nushell.git
synced 2025-03-25 14:07:26 +01:00
Refactor header extraction
This commit is contained in:
parent
ec0bd20f29
commit
1b9c006696
@ -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))
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user