Read csv from stdin too
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Guillem Borrell 2023-01-17 12:18:08 +00:00
parent e4e9b71674
commit 1e18c9ae9f

View file

@ -110,13 +110,14 @@ fn main() {
) )
.get_matches(); .get_matches();
if let Some(_matches) = matches.subcommand_matches("csv") { if let Some(_matches) = matches.subcommand_matches("csv") {
if let Some(path) = _matches.get_one::<String>("path") { let mut ldf = if _matches.get_flag("stdin") {
let mut ldf = LazyFrame::default(); io::load_csv_from_stdin()
if _matches.get_flag("stdin") {
ldf = io::load_csv_from_stdin();
} else { } else {
ldf = io::read_csv(path.to_string()); let path = _matches
} .get_one::<String>("path")
.expect("Please, provide a file");
io::read_csv(path.to_string())
};
if let Some(query) = _matches.get_one::<String>("query") { if let Some(query) = _matches.get_one::<String>("query") {
ldf = sql::execute(ldf, query); ldf = sql::execute(ldf, query);
} }
@ -137,7 +138,6 @@ fn main() {
} }
} }
} }
}
} else if let Some(_matches) = matches.subcommand_matches("sql") { } else if let Some(_matches) = matches.subcommand_matches("sql") {
if let Some(statement) = _matches.get_one::<String>("statement") { if let Some(statement) = _matches.get_one::<String>("statement") {
let ldf = if _matches.get_flag("text") { let ldf = if _matches.get_flag("text") {