'python for loop logic not working properly for write csv file
I have two list and I want to only write csv file based on for loop condition.
box = soup.select('.item__top_container⤍ListItem⤚3pRrO')
for i in box:
job_title = i.select('.item__title⤍ListItem⤚2FRMT')[0].text.replace('opportunity',' opportunity').strip()
job_title = job_title.lower()
time_posted = i.select('time')[0].text.lower()
remove_month_year = ["month","year"]
keywords = ['scrape']
for key_word in keywords:
if key_word.lower() in job_title:
for remove_m_y in remove_month_year:
if remove_m_y.lower() not in time_posted: #it's writing csv file where I added logic not to write csv if month and year present in list
with open("ppp.csv", "a", encoding="utf-8", newline='') as f:
writeFile = csv.writer(f)
writeFile.writerow(
[url,job_title,time_posted,proposal])
my key_word for loop working and only writing csv file if my targeted keyword found in job_title but remove_m_y for loop not working and also writing the csv file where I added logic to not write csv file if "month","year" present in time_posted.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
