Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8710311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:35:52+00:00 2026-06-13T04:35:52+00:00

I am currently having a bit of an issue trying to parse a table

  • 0

I am currently having a bit of an issue trying to parse a table into an array.

I have a simple table (HERE) which I need to parse with BS4 and put the cell contents into an array. What makes things difficult here is the fact that the cells don’t contain text, but rather have images which have these titles:
“Confirm” or “Site” – this is just user right’s stuff.
[I am skipping row one which contains the checkboxes, those i can extract without problems]

If you look at the fiddle above, all I need to do is to parse it in such a way that the resulting array becomes:

Array1[0] = User1,Confirm,Confirm,Site,Confirm
Array1[1] = User2,Confirm,Confirm,Confirm,Confirm
Array1[2] = User3,Confirm,Confirm,Confirm,Confirm
Array1[3] = User4,Confirm,Site,Site,Confirm

Which I can then do as I please with.
Another complication is that sometimes the number of rows will vary so the script should be able to adapt to this and recursively create the array from the table.

At the moment StackOverflow is my only hope.. I have spent the last 10 hours doing this myself with little to no success and frankly I have lost hope. Closest I got to getting something out was extractin the enclosed tags, but could not parse further for some weird reason, perhaps it’s bs4’s nesting limitation? Could anyone have a look, please, and see if they can find a way of doing this? Or at least explain how to get there?

var explanations:
rightml – the soup for the table.

allusers = []
rows = rightml.findAll('tr')
for tr in rows:
    cols = tr.findAll('td')
    for td in cols:
        if (td.find(title="Group")) or (td.find(title="User")):
            text = ''.join(td.text.strip())
            allusers.append(text)
print allusers

gifrights = []

rows7 = rightml.findAll('td')
#print rows7
for tr7 in rows:
    cols7 = tr7.findAll('img')
    for td7 in cols7:
        if (td7.find(title="Confirm")) or (td7.find(title="Site")):
            text = ''.join(td7.text.strip())
            text2 = text.split(' ')
            print text2
            gifrights.append(text2)

I could be WAY off with this code.. but I gave it the ol’ college try.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T04:35:53+00:00Added an answer on June 13, 2026 at 4:35 am

    Would something like this work:

    rows = soup.find('tbody').findAll('tr')
    
    for row in rows:
        cells = row.findAll('td')
    
        output = []
    
        for i, cell in enumerate(cells):
            if i == 0:
                output.append(cell.text.strip())
            elif cell.find('img'):
                output.append(cell.find('img')['title'])
            elif cell.find('input'):
                output.append(cell.find('input')['value'])
        print output
    

    This outputs the following:

    [u'Logged-in users', u'True', u'True', u'True', u'True']
    [u'User 1', u'Confirm', u'Confirm', u'Site', u'Confirm']
    [u'User 2', u'Confirm', u'Confirm', u'Confirm', u'Confirm']
    [u'User 3', u'Confirm', u'Confirm', u'Confirm', u'Confirm']
    [u'User 4', u'Confirm', u'Site', u'Site', u'Confirm']
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a bit of an issue wrapping my head around something. I'm currently
I'm having a bit of an issue and, the other questions here didn't help
I am having an issue with the following bit of code. I'm trying to
Im having a bit of an issue where i create an array of button
Seem to be having a bit of an issue trying to draw my view
I'm currently working with PowerPoint in VB.NET and having a bit of trouble getting
I am having a bit of difficulty with this current code I have set
I am currently having unnecessary trouble trying to test out RubyMine. My biggest problem
G'day guys, Trying currently to finish up a bit of homework I'm working on,
I am currently having a minor issue with a Java Jframe and a button

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.