TypeError: a bytes-like object is required, not ‘str’ in python and CSV

TypeError: a bytes-like object is required, not ‘str’ getting above error while Executing below python code to save the HTML table data in Csv file. don’t know how to get rideup.pls help me. import csv import requests from bs4 import BeautifulSoup url=”http://www.mapsofindia.com/districts-india/” response=requests.get(url) html=response.content soup=BeautifulSoup(html,’html.parser’) table=soup.find(‘table’, attrs={‘class’:’tableizer-table’}) list_of_rows=[] for row in table.findAll(‘tr’)[1:]: list_of_cells=[] for cell … Read more

How can I truncate table cells, but fit as much as content possible?

Meet Fred. He’s a table: <table border=”1″ style=”width: 100%;”> <tr> <td>This cells has more content</td> <td>Less content here</td> </tr> </table> Fred’s apartment has a bizarre habit of changing size, so he’s learned to hide some of his content so as not to push all the other units over and shove Mrs. Whitford’s living room off … Read more