Sharing the required code as asked for the previous doubt

The code is attached below
tables = android_soup.findAll(‘table’,{‘class’: ‘wikitable’})
print(len(tables))
android_table = tables[0]
print(android_table)
headers = android_table.findAll(‘th’)
print(len(headers))
print(headers[1].text)
column_titles = [ct.text[:-1] for ct in headers]
print(column_titles)
rows_data = android_table.findAll(‘tr’)[1:]
print(len(rows_data))
first_row = rows_data[0].findAll(‘td’,{})
for d in first_row:
print(d.text[:-1])

table_rows = []
for row in rows_data :
current_row =[]
row_data = row.findAll(‘td’,{})
for idx,data in enumerate(row_data):
if idx!=0 and idx!=2:
current_row.append(data.text[:-1])
else:
current_row.append(data.text)
table_rows.append(current_row)
print(table_rows)
filename = ‘android_version_history.csv’
with open(filename,‘w’, encoding = ‘utf-8’) as f:
header_string = ‘,’.join(column_titles)
header_string += ‘\n’
f.write(header_string)

for row in table_rows:
    row_string = ""
    row_string = ','.join(row)
    row_string += '\n'
    f.write(row_string)

hey @ayushU2x ,
sorry to trouble you again.

But the code is quite messy here , and not properly understandable.
can you just do me a favour.
upload the code file and your output submission in drive and share me the link.

Sorry again.
Thank You :slight_smile:.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.