Automating with Python and ChatGPT

A practical guide for non-programmers

Automation python chatgpten

Have you ever spent an hour copying data from one file to another thinking "there must be a better way"?

There is.

It's called Python, and with the help of ChatGPT you can use it even if you've never written a line of code in your life.

What is Python and why is it useful for automating

Python is one of the most widely used programming languages in the world, prized especially for its readability: code almost resembles spoken English, making it accessible to non-technical people. Its real strength is its libraries, add-on modules that install in seconds and greatly extend its capabilities.

Basically, with Python you can automate tasks such as:

  • converting CSV files to Excel or HTML and vice versa
  • generating automatic PDF reports from spreadsheets
  • sending emails with attachments automatically
  • extracting text from scanned documents (OCR)
  • batch renaming and organizing files
  • downloading and storing files from server or cloud
  • extracting data from PDFs or mailboxes
  • connecting to external APIs to import or export data
  • creating automatic alerts based on conditions in a database

If any of these activities sound familiar, you already have a good reason to read on.

How ChatGPT comes into play

ChatGPT, the artificial intelligence tool developed by OpenAI, can answer questions, generate text and, most importantly, write code. This changed the rules of the game forever: instead of learning to program from scratch, you just describe to ChatGPT what you want to achieve and the chatbot returns you ready-to-use Python code.

The more you know about programming, the better you will understand the generated code and be able to adapt it when necessary. But even starting from scratch, you can get functional scripts to automate real-world tasks.

If you are curious about how AI can integrate into business processes in a more structured way, take a look at our AI integration services.

How to access ChatGPT

To get started, you need an account on OpenAI:

  1. Go to openai.com and click on "Register."
  2. Enter your email and create a password.
  3. Verify your email address.
  4. Access ChatGPT from chat.openai.com.

ChatGPT is available in multiple versions: the free one is sufficient for generating simple scripts (it is sometimes slower and subject to usage limits). While with ChatGPT Plus (about 20 euros per month) you get priority access to the latest models, faster responses and better performance. For frequent and professional use, the Plus version is worth the investment.

However, there are many viable alternatives: Google Gemini, Microsoft Copilot and Claude (from Anthropic) can generate Python code with comparable results, often with more generous free plans.

How to install Python on Windows

To run the code generated by ChatGPT, you must install Python on your computer:

  1. Go to python.org/downloads and download the latest version.
  2. Start the downloaded file.
  3. Important: if you are on Windows, check the "Add Python to PATH" box before proceeding.
  4. Click on "Install Now" and wait for completion.

To verify that the installation was successful, open the terminal and type:

python --version

If you see a version number, it means Python is installed.

How to open the terminal on Windows: press Win + R, type cmd and press Enter. Alternatively, search for "cmd" or "Terminal" in the Start menu.

How to write effective prompts to generate code

The quality of the generated code depends a lot on how you formulate the request. Some rules of thumb:

Be specific: instead of "write a code to manage files," say "write a Python script that renames all .jpg files in a folder by adding today's date to the beginning of the name."

Indicate some examples: if possible, show ChatGPT an example of the input file and how you want the output.

Ask for explanations: if you don't understand a part of the code, ask "What does this line do?" or "Can you explain how this block works in Italian?" ChatGPT is patient and never gets tired.

Specifies operating system: some file paths and commands change between Windows, Mac, and Linux. Say it right away to avoid unnecessary mistakes.

Once you get the code, remember that it may contain placeholders that you have to fill in manually: file paths, API keys (identification codes to connect to external services), login credentials. Always read all the code before running it.

How to install additional libraries

Many scripts require external libraries that are not included in the basic Python installation. To install them, use the pip command from the terminal:

pip install library-name

For example, to install pandas (useful for working with spreadsheets):

pip install pandas

To see all the libraries already installed:

pip list

If the installation gives problems, update pip with:

python -m pip install --upgrade pip

If you are not sure which libraries you need, ask ChatGPT directly: "What libraries should I install to run this script?"

How to handle errors

Scripts do not always work on the first try, and that is completely normal. Here is how to deal with the most common problems:

The script hangs or does not respond: stop execution with Ctrl + C from the terminal.

An error message appears: copy it in full and paste it into ChatGPT with the message "I have this error, how do I fix it?" You usually get a solution within seconds.

ChatGPT keeps suggesting incorrect variants. It happens, especially on complex problems. In these cases, the most efficient thing to do is open a new conversation and start from scratch with a more detailed prompt. Persisting in the same chat rarely gets you anywhere.

File path errors: check that the path to the folder or file is spelled correctly. On Windows, backslashes (\) can cause problems: ask ChatGPT to use regular slashes (/) or handle them in a compatible way.

Is it worth doing?

It depends on the case. Before investing time in developing a script, ask yourself:

How much time will it take me to do this by hand? If it's a one-time task that you can complete in twenty minutes, it's probably not worth automating.

How often will I have to repeat this? If the answer is "every week" or "every time a new file arrives," then a script that takes you an hour to develop will pay for itself in a few weeks.

How complex is it? Simple, well-defined tasks are quickly automated. Processes with many exceptions or that depend on human judgement are more difficult to reliably automate.

If the answer sounds like "yes, but I don't have the time or inclination to do it myself," there is another option: trust someone to do it for you. We are not talking about the colleague who "knows a little bit about it," but an experienced consultant who already knows where the problems lie.

Our process automation services are designed exactly for this: identify the right activities, build the scripts or automation flows, and guide you through adoption. If you want to do some training first to better understand what this is all about, we also have dedicated paths.

Essential steps to get started creating Python scripts with ChatGPT

If you have read this far and want to try it, here is the easiest route:

  1. Create a free account on ChatGPT.
  2. Install Python on your computer.
  3. Think of a repetitive task that you do regularly (renaming files, converting formats, extracting data).
  4. Describe the problem to ChatGPT as precisely as possible.
  5. Run your code, handle any errors with the help of AI.
  6. Evaluate how much time it saved you.

The first working script is the most difficult. Then it becomes almost a habit.

Technical translator, project manager, entrepreneur. Languages graduate with an MA in Design and Multimedia Production. He founded Qabiria in 2008.

Further Reading

Chat to one of us

Let us know what you need by sending an email to hola@qabiria.com or by filling in the contact form. We guarantee a response within 24 hours, but usually we’re much faster.

Contact us