Parsing HTML Tables

Can anyone help me resolve the issue of extra "\n"s being printed as output?

Hey @developerkushal, you need to remove it individually from the columns by iterating over them, there’s no direct way to do it.

Hope this cleared your doubt. :blush:

But the question is why did the "\n"s not show up when Prateek Bhaiya did it in the tutorial?

I think you need to change “if idx==0 or idx==3:” instead of “if idx!=0 and idx!=3:”.

Sorry, it’s wrong. Try again.

Share your ipynb notebook after uploading it on google drive and sharing the link here.

Here you go:

https://drive.google.com/file/d/1raTajQuTplExs5F3jXTSeV31560iZwe7/view?usp=sharing

Use this code,
table_rows = []
for row in rows_data:
current_row = []
row_data = row.findAll(‘td’, {})
for idx,data in enumerate(row_data):
current_row.append(data.text[:-1])
print(current_row)
table_rows.append(current_ro

It will print desired results.

1 Like

Thank you so much for helping me out! :smile: