Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple List manipulation - bowled
#5
Got you. Thanks Do you think we can improve the code little better. I do not want list comprehension as it is confusing :)
appPath = 'D:\\Backup\\Drive_D\\W0rk\\Script\\Python\\HTMLTOCSV_Python\\Try\\'

cols=[]
newcols=[]
from bs4 import BeautifulSoup
import os

soup = BeautifulSoup(open(appPath+'Cust\\consolidated_report_201708100600Copy.html','rb'), 'lxml')
h1 = soup.find_all("h1")
for col in h1:
    cols.append(col.get_text())
for item in cols:
    technology = item.split(':')[0]
    color = item.split(':')[-1]
    if color in ["red","yellow"]:
        newcols.append((technology,color))
        newcols.sort(reverse=True)
newcols = dict(newcols)

print(newcols)
Reply


Messages In This Thread
Simple List manipulation - bowled - by radioactive9 - Aug-11-2017, 01:54 AM
RE: Simple List manipulation - bowled - by radioactive9 - Aug-11-2017, 03:28 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020