Scrape data and write in single line for every iteration BS4 python
Question: I have the following code. It all scraping the data. But my concern is to
write the data in a single line for each iteration it goes.

Here is my code

    
    
    import bs4 as bs
    import urllib2
    import re
    
    page = urllib2.urlopen("http://www.codissia.com/member/members-directory/?mode=paging&Keyword=&Type=&pg=1")
    content = page.read()
    soup = bs.BeautifulSoup(content)
    eachbox = soup.find_all('div', {'class':re.compile(r'members_box[12]')})
    for eachuniversity in eachbox:
        data =  [re.sub('\s+', '', text).strip().encode('utf8') for text in eachuniversity.find_all(text=True) if text.strip()]
        print(','.join(data))
    

**UPDATE**

I want to the output to be like this (in single line) for an iteration

    
    
    Name:,Mr.Srinivasan.N,Designation:,Proprietor,CODISSIA - Designation:,(Past President, CODISSIA),Name of the Industry:,Arian Soap Manufacturing Co,Specification:,LIFE,Date of Admission:,19.12.1969, "Parijaat" 26/1Shanker Mutt Road, Basavana Gudi,Phone:,2313861
    

But I am getting as follows

    
    
    Name:,Mr.Srinivasan.N,Designation:,Proprietor,CODISSIA - Designation:,(Past President, CODISSIA),Name of the Industry:,Arian Soap Manufacturing Co,Specification:,LIFE,Date of Admission:,19.12.1969
    "Parijaat" 26/1Shanker Mutt Road, Basavana Gudi,Phone:,2313861
    


Answer: `eachbox` is either class `members_box1` or `members_box2`, so iterating over
`eachbox` will print every box contents on a separate line, when really you
want both on one line. One way to get around this would be like this:

    
    
    box1s = soup.find_all('div', class_='members_box1')
    box2s = soup.find_all('div', class_='members_box2')
    for box1, box2 in zip(box1s, box2s):
        data =  [re.sub('\s+', '', text).strip().encode('utf8') for text in box1.find_all(text=True) + box2.find_all(text=True) if text.strip()]
        print(','.join(data))
    

