Micro Guide to Calculations with Python + Chatgpt

More
1 year 11 months ago - 1 year 11 months ago #24101 by prashant
Hellos newbie,
I am fellow newbie,The stance of ETL-tools team is simply calculations are slow and should be avoided. I totally agree .

BUT If you still want to use calculations using python, here are some guidelines for chatGPT which you can copy paste before asking it what to do 
Here's a summarized guideline for writing and running Python scripts in the described style, specifically tailored for use within ETL-Tools calculations:

---
COPY PASTE FROM HERE 

I want to make python script but I want you to follow these guidelines.Yes, I understand. Here's your input formatted and ready to be used. If you understand them give me yes/no , so I can proceed

Guidelines for Immediate Execution Python Scripts in ETL-tools using Caluclations
  • Immediate Execution The script is executed from top to bottom without needing any special entry point like `main()`.
  • Output Specification The result must always be assigned to `Result.value`. This is case-sensitive; using `result.value` will not work.Always assign the final result to `Result.value`.
  • No Printing The output should not be printed; it must be assigned to `Result.value`.
Handling Input Variables
  • String Inputs All input variables passed into the script are strings by default.
  • Be Default , ETL-Tools passes variables into Python using `[F001]`, `[F002]`, `[F003]`, etc. These variables can be referred to directly in the calculations. As given above they will always be string
  • Conversions Convert input strings to the required types (e.g., integer, array) within the script.
Important Notes 
  • Result Initialization : There is no need to initialize the
    Code:
    Result
    class within the script.
    Code:
    Result.value
    is always initialized by ETL-Tools.
  • Direct Variable Reference: You can directly refer to ETL-Tools variables and perform necessary calculations without intermediate assignments.
Example
In this simple example , we want to add 200 to our value . Default variables are with [F001] , you assign it a number , 54 in our case 

Result.value=int([F001])+200
 

In Editor window , notice we convert F001 back to integer . Press Run Button
 

Congrats you've run your first script.
 
Last edit: 1 year 11 months ago by prashant.
The following user(s) said Thank You: admin, Peter.Jonson

Please Log in or Create an account to join the conversation.

More
1 year 11 months ago #24129 by admin
FYI: We have updated wiki based on the information you provided

www.etl-tools.com/wiki/knowledgebase/tips/working-with-python/

Mike
ETL Architect

Please Log in or Create an account to join the conversation.

More
1 year 11 months ago #24130 by prashant

FYI: We have updated wiki based on the information you provided

www.etl-tools.com/wiki/knowledgebase/tips/working-with-python/
Wohoo !! Hoping it becomes easier for new users to try ETL-tools

Please Log in or Create an account to join the conversation.

Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Read more
Marketing
Set of techniques which have for object the commercial strategy and in particular the market study.
Google
Accept
Decline
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline
Google Analytics
Accept
Decline
Functional
Tools used to give you more features when navigating on the website, this can include social sharing.
Advertisement
If you accept, the ads on the page will be adapted to your preferences.
Google Ad
Accept
Decline
Save