title: How to associate specific rows coming from webscraping in a CSV file?
body: <p>I'm currently working on webscraping process by using python and more especially BeautifulSoup package in order to extract for each article of each page text and topics from a web page<a href="https://www.unep.org/resources?keywords=along%20with%20a%20vow%20to%20return%20to%20exerc&amp;f%5B0%5D=category%3A451&amp;f%5B1%5D=type%3A55" rel="nofollow noreferrer">1</a>)</p>
  <p>For each article, I would like to regroup each <strong>texts</strong> extracted in one single string and associate to it a string of the <strong>topic.s</strong>. The goals is to iterate this process for all article and obtain a CSV file with a Text and Topic column (each line represent an article)</p>
  <pre><code>Texts = []
  Topics = []
  
  
  with open('urls.txt', 'r') as inf:
      with open('text_file.csv', 'w') as outf:
          outf.write('Text, labels\n')
          for row in inf:
              url = row.strip()
              response = requests.get(url, headers={'User-agent': 'Mozilla/5.0'})
              if response.ok:
                  soup = BeautifulSoup(response.text,'lxml')
                  txt = soup.findAll('div', {'class': 'para_content_text'})
                  for div in txt:
                      p = div.findAll('p')
                      Texts.append(p)
                  for result in Texts:
                      for item in result:
                          full_text = ' '.join([item.text for result in Texts for item in result])
                         
  
                          
              top = soup.find('div', {'class': 'article_tags_topics'})
              a = top.findAll('a')
              Topics.append(a)
              for res in Topics:
                  for it in res :
                      full_topic = ' '.join([it.text for res in Topics])
              
              outf.write(full_text.replace(',','') + ',' + full_topic + '\n')
  </code></pre>
  <p>But after running my code I obtained text cells repeated several times because each repetition is associated to a different topic. the topics are also repeated themselves (see attached screenshot to have a better idea)<a href="https://i.stack.imgur.com/R7XzS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/R7XzS.png" alt="enter image description here" /></a></p>
  <p>How can avoid these multiple line repeats ?</p>