Source
yaml
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}")
About this blueprint
Inputs Python Software Engineering
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.