Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 PyQt5: Iterate through rows to check for a value
#1
Hi, I am trying to use a for loop to check every row of a table for a certain value and then either add 1 or 0 to a list. I am currently trying:
            for row in range(rowPosition):
                item = self.invoice.item(row, 0)
                itemText = item.text()
                if itemText == "value being searched for":
                    test.append(1)

                else:
                    test.append(0)
            ##rowPosition is rowCount()

When i try this, it just fails, I did try the item function putting a certain row in and that works, but it will not use the row value.
Thanks in advance.
Quote
#2
please show:
  • What type of file (csv, txt, or whatever)
  • code prior to for loop (a runnable snippet is best)
  • If you can, entire script
Quote
#3
Don't worry, I got it working, I just had to set the range to 1, rowPosition.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Huge code problems (buttons(PyQt5),PyQt5 Threads, Windows etc) ZenWoR 0 535 Apr-06-2019, 11:15 PM
Last Post: ZenWoR
  PyQt5: Add Variable Number of Rows to Layout Based on Python Dictionary kennybassett 2 1,419 Oct-02-2018, 02:05 PM
Last Post: Alfalfa

Forum Jump:


Users browsing this thread: 1 Guest(s)