-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: blueprint for python input file (#26)
* feat: blueprint for python input file * Apply suggestions from code review --------- Co-authored-by: Will Russell <[email protected]>
- Loading branch information
1 parent
4bef3d3
commit be2d78d
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
id: python-input-file | ||
namespace: company.team | ||
|
||
tasks: | ||
- id: download_file | ||
type: io.kestra.plugin.core.http.Download | ||
uri: https://huggingface.co/datasets/kestra/datasets/raw/main/csv/orders.csv | ||
|
||
- id: get_total_rows | ||
type: io.kestra.plugin.scripts.python.Script | ||
beforeCommands: | ||
- pip install pandas | ||
inputFiles: | ||
input.csv: "{{ outputs.download_file.uri }}" | ||
script: | | ||
import pandas as pd | ||
# Path to your CSV file | ||
csv_file_path = "input.csv" | ||
# Read the CSV file using pandas | ||
df = pd.read_csv(csv_file_path) | ||
# Get the number of rows | ||
num_rows = len(df) | ||
print(f"Number of rows: {num_rows}") | ||
extend: | ||
title: Pass an input file to a Python script | ||
description: >- | ||
This flow runs a Python script that takes an input file and processes it. | ||
The first task `download_file` downloads the CSV file. | ||
The second task is a Python script task that takes the downloaded CSV file as an input file, | ||
and processes it to find the number of records in the file. | ||
tags: | ||
- Python | ||
- Inputs | ||
- Software Engineering | ||
ee: false | ||
demo: true | ||
meta_description: This flow runs a Python script that takes an input file and processes it. |