Python Forum
Get the info from 2 different rows in the same column using a one key
Thread Rating:
  • 2 Vote(s) - 4.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get the info from 2 different rows in the same column using a one key
#1
Hi all,
Again I need your support!
I have the following excel file info:

Using the key “Site ID” I want to find the VLAN XXX about the key1 but if you observe the excel I have 2 rows for the same key1, I have the identification for the first row as “key1” and for the second row it’s blank but nevertheless that row also contains info about “key1”.

[Image: o5zjhL3]

this is the coding:
 excel_file = u'*Personal SUR GUL EPT 20190103*'
 controller_file = u'*IPs Controladoras*'
 ip_plan_file = u'*IP PLAN South_2*'
 controller_Dict = LOAD_EXCEL_FILE(controller_file, "Sheet1", 1, "key2")
 ip_plan_Dict = LOAD_EXCEL_FILE(ip_plan_file, "Sheet2", 1, "Site ID")
 Site_2G_Dict = LOAD_EXCEL_FILE(excel_file,"Sheet3", 1, "Site Name")
 
 Base_Station_row_list = []
 Site_list = READ_TXT_FILE("site_list")
 for sites in Site_list:
     if sites not in Site_2G_Dict.keys(): # Check if SiteID exist in excel file
         print sites, "Not present in Personal excel file"
         continue
 		
 Site_2G_Info = Site_2G_Dict[sites]
 h = Site_2G_Info[0].attr("Site ID")
 
 # Device IP Address info
     for device_ip in ip_plan_Dict:
         if device_ip != h: continue
         device_ipplan_info = ip_plan_Dict[device_ip]
         i = device_ipplan_info[0].attr("IP Address")
with this coding, I can get the IP Address info “i = 10.1.2.1/30” but I don’t want the IP I want the VLAN XXX info “i = VLAN 1000”
Thanks in advance
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  What is all the info in the info window in Idle? Pedroski55 3 700 Jul-08-2023, 11:26 AM
Last Post: DeaD_EyE
  How to assign a value to pandas dataframe column rows based on a condition klllmmm 0 843 Sep-08-2022, 06:32 AM
Last Post: klllmmm
  The code I have written removes the desired number of rows, but wrong rows Jdesi1983 0 1,636 Dec-08-2021, 04:42 AM
Last Post: Jdesi1983
  Pandas DataFrame combine rows by column value, where Date Rows are NULL rhat398 0 2,117 May-04-2021, 10:51 PM
Last Post: rhat398
  Indexing [::-1] to Reverse ALL 2D Array Rows, ALL 3D, 4D Array Columns & Rows Python Jeremy7 8 7,134 Mar-02-2021, 01:54 AM
Last Post: Jeremy7
  How to filter out Column data From Multiple rows data? firaki12345 10 5,127 Feb-06-2021, 04:54 AM
Last Post: buran
  how to combine rows to a column base on ids zhujp98 0 1,499 Nov-03-2020, 04:10 PM
Last Post: zhujp98
  How to generate rows based on values in a column to fill missing values codesmatter 1 2,139 Oct-31-2020, 12:05 AM
Last Post: Larz60+
  How to diff pandas rows and modify column value Mekala 1 1,702 Sep-18-2020, 12:38 PM
Last Post: Mekala
  Column to rows kmrashish1985 0 1,297 Aug-20-2020, 09:15 PM
Last Post: kmrashish1985

Forum Jump:

User Panel Messages

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