Hi, Below is my output:

FF 0 CMA: 0 IPMI port
DE 15E0 TTA: 1 Generic Com port
DD 15D0 TTB: 2 Generic Com port
DC 15C0 SEA: 3 ACPI System Event
FF 0 1 MFPCI
DB 15B0 DQA: 2 CMD 649 IDE/ATA Controller
DA 15A0 EIA: 3 Intel 82557 LOM (Fast Ethernet)
D9 1590 OHA: 1 NEC OHCI USB Controller
D8 1580 OHB: 1 NEC OHCI USB Controller
D7 1570 EHA: 1 NEC EHCI USB Controller
FF 0 1 MFPCI
D6 1560 EWA: 2 BCM5701 LOM (Gigabit Ethernet)
D5 1550 PKA: 1 LSI Logic 1030 U320
D4 1540 PKB: 1 LSI Logic 1030 U320
D3 1530 PKC: 4 Smart Array 6400 series
D2 1520 PKD: 5 Smart Array 6400 series
FF 0 1 MFPCI
D1 1510 GHA: 2 ATI Radeon 7000
DF 15F0 1 1291103C.1290103C (<...<...)
DF 15F0 SRA: 1 Console Serial Line Driver

From this output I want get only 0,1,2,3,1,2,3,1,1,1,1,2,1,1,4,5,1,2,1,1 only when I am printing 3 array index then some cases I am getting MFPCI and 1291103C.1290103C. Please let me know how can I get this value??????

The problem is that not all the data has the same format and the numbers you are looking for are in different "array" positions for some lines if you split those lines based on whitespace. For example:
DE 15E0 TTA: 1 Generic Com port => Number 1 is at offset 3
FF 0 1 MFPCI => Number 1 is at offset 2

Note that when the number you want is at offset 3, then the data at offset 2 is a non-numeric value ending with ":"

You could take advantage of this by:
For each line, split based on whitespace and examine the data at offset 2. If it does not end with a ':' then you can use this as your value otherwise take the data at offset 3.

Hi, Thanks for ur reply but I tried everything and not getting the desired output. Even I am new to Python also so I don't know how to proceed thru ur logic. It would be great if u can send me some working code. Thanks Krishna_sicsr

The problem is that not all the data has the same format and the numbers you are looking for are in different "array" positions for some lines if you split those lines based on whitespace. For example:
DE 15E0 TTA: 1 Generic Com port => Number 1 is at offset 3
FF 0 1 MFPCI => Number 1 is at offset 2

Note that when the number you want is at offset 3, then the data at offset 2 is a non-numeric value ending with ":"

You could take advantage of this by:
For each line, split based on whitespace and examine the data at offset 2. If it does not end with a ':' then you can use this as your value otherwise take the data at offset 3.

Here you go, let me know if you need any more help. Note that I'm assuming that the data has been read into an array called lines with each line of text as a separate array entry. The code below gives you the desired numbers.

for line in lines:
    parts = line.split()
    if parts[2][-1] == ':':
        print parts[3]
    else:
        print parts[2]
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.