Forums

Text to CSV script

I know nothing about Python. ChatGPT wrote a script to process a .txt file to .csv. I have uploaded the script into a console (3.7). Now what?

Background: I am an elevator service supervisor, and the state, that I live in, publishes an online PDF file with the current status and renewal requirements of the elevator licenses. This database is updated regularly, but it is difficult to work with. I am able to download the PDF, but because of its size, PDF to XLS converters don't work. I can easily convert the pdf to txt, and ChatGPT did an excellent job of converting a sample to CSV. However, I can't upload the entire file to GPT. So GPT wrote a python script to convert the entire text file to csv. However, I'm not familiar with Python and keep hitting roadblocks.

Any help is appreciated.

Hey dude. The following information may be helpful for you to get started with PythonAnywhere. Hope it helps!! :D

There are lots of programming languages to choose from, depending on what you want to create, but Python is a great programming language to begin coding with. It requires that your code be written out in a way that’s easy to read, and it is good for writing both small and large programs.

One of the easiest ways to get started writing Python is to use the browser-based app PythonAnywhere. Because it runs in a browser, you don’t need to download or update any code on your own computer.

Creating an Account Navigate to PythonAnywhere, and click the blue button labeled Create a Beginner account.On the PythonAnywhere webpage signup screen, a blue button is labeled “Create a Beginner account”. Once you create your account, you’ll be able to see your Dashboard.

This is where you can see your files. Searching for files without saving them in folders is not a strategy that will work well in PythonAnywhere! PythonAnywhere uses a file system with folders organized in a way that is actually quite important for how your code will talk to other files.

Once you have logged into PythonAnywhere, click on the Files tab at the top right of the window so you can take a look.

In PythonAnywhere, you’ll notice that you have a Home folder, inside of which is a folder with your username.

You can create further folders to organize your folders more as you learn to code, but for now, we are going to stay with the Home folder. When we’re coding a big project like a website or video game, we will end up with a lot of files that need some organization. Just like we organize our school papers into folders, we’ll want to organize our coding files in a coherent way. A more general term for this structure of computer folders is directory. The terms “directory” and “folder” are more or less interchangeable, but directory is slightly more formal and lots of computer scientists prefer this term.

So, what kinds of files might we have for our website project? First, there would be our main Home folder, inside of which we might keep a main folder that houses all of our website files. We could call this folder MySite. Beyond this, we might also have a folder that holds all of the web templates we’ve written. For example, maybe there would be a blog post template that we could use every time we wrote a blog post. We could call this folder Templates.

Now, how would we identify the location of the Templates folder? We’d use its unique file path! Let’s see how this would look on PythonAnywhere.You’ll notice at the top of the window that we see all of the names of our folders, culminating in the Templates folder. But what do those slashes mean? There are several different ways that file paths have been designated over computing history.

In the folder you want to create a file for, just type insert the new filename in the field under Files and click the New file button. By adding an extension after the filename, you specify what type of file for PythonAnywhere to create. The .py ending to the file is important because it tells the computer that this file contains Python code.

@Connor4school, thanks for the useful post!

@jlee0639, we (the tech support team) can't really give coaching in programming, but in addition to the post above, you might find this list of resources for learning Python useful.

When using Chat GPT you have to be very specific with what you want... I'd begin with project flow. Literally write down a flow chart with module names and definitions of what you what to happen at each stage. Describe this to Chat GPT in a short paragraph and ask for insight and suggests. Be specific with how you want it to format with examples etc. Once you know the flow of how the data should be manipulated, it should be much easier to understand the Chat GPT code snippets. Also, use I'd suggest Chat GPT4.