Python Forum
Not sure what to call what I want to do
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Not sure what to call what I want to do
#11
yeah the point of me writing up an example was for you to actually change your content.
Recommended Tutorials:
Reply
#12
(Oct-12-2018, 07:13 PM)metulburr Wrote: yeah the point of me writing up an example was for you to actually change your content.

Still working on that I just needed to have something functional for a demo.


    pp = pprint.PrettyPrinter()
 
soup = [
['\ufeff73450', 'New Hope Electric Company of Washington, Inc.', 'CI-120 - West Port Hall Student Commons - AC-Aiphone-Intrusion-CCTV', 'Location', 'Part#', 'Description', 'Curr Qty', 'M2C2', '6702UE 888U1000', 'Cable - 4 Conductor-SSA-Plenum-Box-Unshielded-22AWG/4-Stranded-Natural', '1000', ''],
['\ufeff76805', 'JM Wentworth, Inc.', 'JMW - Westport - Buildout', 'Location', 'Part#', 'Description', 'Curr Qty', 'L1B2', '98756-U48', 'Patch Panel-Cat6-48 Port-2U-Loaded-Universal-Black', '1', 'L1B3', '65756-U24', 'Patch Panel-Cat6-24 Port-1U-Loaded-Universal-Black', '1', 'M3B4', '95-050-41-X', 'Fiber Connector-MM-Unicam-Ceramic-SC-50/125-OM3/OM4-High performance-Aqua', '24', 'M3B7', 'RIC-F-SC12-01', 'Fiber Bulkhead-SM/MM-6 Duplex-12 Adapters-SC-Black', '2', 'M3B9', 'RIC-F-BLNK-01', 'Fiber Bulkhead - Blank-Black', '4', 'M3C9', '852-L42-009', 'Fiber Patch Cord-MM-LC-SC-Duplex-50/125-Riser/CMR-3 M-Value Series-Aqua', '2', 'M2C88', '000-050', '"Fiber Ground- Connector-MC-.5"" NWT Metallic"', '2', 'M4C7', '566-000-005', 'Copper Patch Cord-Cat6-RJ45-RJ45-5 Ft-No boot-PVC-Stranded-Value Series-Blue', '37', 'M4C6', '2601-00000-015', 'Copper Patch Cord-Cat6A-RJ45-RJ45-15 Ft-Snagless-PVC-Shielded-Stranded-Gray', '2', '']
]
data = {}
#assign key names to known indexes
for lst in soup:
    key = lst[1] #set the second element (the name) of each list as the dictionary key
    data.update({key:{}})
    data[key].update({'job_number':lst[0]})
    data[key].update({'job_location':lst[2]})
    data[key].update({'loc':lst[7]})
    data[key].update({'part':lst[8]})
    data[key].update({'desc':lst[9]})
    data[key].update({'qty':lst[10]})
     
pp.pprint(data) # example of data organized
#assign output presentation
for k in data:
    d = f'''
    | Job Number: {' ': <25} {data[k]['job_number']} |
    | Job Name: {' ': <25} {k} |
    | Job Location: {' ': <25} {data[k]['job_location']} |
 
    '''
    print(d) #now write d to a file instead of printing it
This puts me back in the same spot >>> where I am not sure how to iterate over multiple "job" options.
Reply
#13
(Oct-12-2018, 09:07 PM)SpencerH Wrote: where I am not sure how to iterate over multiple "job" options.
each key should be a nested dictionary of that jobs specific details. If you want to iterate over the jobs then you would just iterate over the dictionaries keys.
Recommended Tutorials:
Reply


Forum Jump:

User Panel Messages

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