How do I take data from a single TKinter entry widget, and append multiple columns in a pandas dataframe?

Viewed 66

So I'm trying to create an inventory tracker for my team, and so far it is going pretty well. Currently, I'm stuck on how to get this part to work properly.

Here's an example of the dataframe I have created using the program with some random items:

I have another small python script to generate QR codes for every row in a given CSV, with the idea being that when I go to my program's tkinter entry widget, scan the QR code with a scanner, and click 'add item to inventory' it will append the CSV with the appropriate information in their respective fields.

The issue I'm struggling with at the moment is that when I enter anything into the entry widget, it all appends to only the 'Name' column in the CSV. Example below:

I was hoping that because it is a CSV, entering the data in a CSV format would achieve the results I was trying to get (item,description,current_inventory) but it just appends whatever I type to the Name column only - commas or spaces or anything... doesn't matter.

How do I get it to take in information from a single tkinter entry widget, and append the specific columns in the dataframe? Is it even possible to do all of this from a single entry widget?

Thanks in advance!

Code:

def addInventoryItem():
    if e.get() != '':
        # TODO
        # Trying to implement appending the CSV with multiple columns populated by scan

        df = pd.read_csv(current_csv)
        addInventoryList = [e.get()]
        df = pd.DataFrame(addInventoryList)

        # Append new dataframe to existing CSV
        df.to_csv(current_csv, mode='a', index=False, header=False)
0 Answers
Related