Skip to content

Commit

Permalink
feat: blueprint for python input file (#26)
Browse files Browse the repository at this point in the history
* feat: blueprint for python input file

* Apply suggestions from code review

---------

Co-authored-by: Will Russell <[email protected]>
  • Loading branch information
shrutimantri and wrussell1999 authored Jan 15, 2025
1 parent 4bef3d3 commit be2d78d
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions python-input-file.yaml
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.

0 comments on commit be2d78d

Please sign in to comment.