473,326 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Removing part of string

Hi,
I am parsing an xml file ,and one part of structure looks
something like this:

- <COMPARAM id="_338" DDORef="_18" Semantics="timing"
PhysicalLink="Infotainment_Control_Bus_CAN">
<SHORTNAME>Infotainment_Control_Bus_CAN_TIMEOUT_AX </SHORTNAME>
<LONGNAME>Timeout N_As/N_Ar</LONGNAME>
<DESCRIPTION>Time from transmit request until a CAN frame transmit
confirmation is received.</DESCRIPTION>
</COMPARAM>

In my code i am extracting the data within
<LONGNAME>,which is Timeout N_As/N_Ar.These tags repeat and will have
different timer names..like

- <COMPARAM id="_339" DDORef="_18" Semantics="timing"
PhysicalLink="Infotainment_Control_Bus_CAN">
<SHORTNAME>Infotainment_Control_Bus_CAN_TIMEOUT_BS </SHORTNAME>
<LONGNAME>Timeout N_Bs</LONGNAME>
<DESCRIPTION>Time that the transmitter of a multi-frame message
shall wait to receive a flow control (FC) frame before timing out with
a network layer error.</DESCRIPTION>
</COMPARAM>

I need to remove the words Timeout from the data,and
take only the abbrevation..i.e.N_As/N_bs like that .In short i have to
remove the words which come with name Time,and also the space which
comes next to it.
and take only the abbreviation.Can someone help me in this.
Thanks

May 14 '07 #1
4 4848

On May 14, 2007, at 12:56 AM, sa**********@gmail.com wrote:
Hi,
I am parsing an xml file ,and one part of structure looks
something like this:

- <COMPARAM id="_338" DDORef="_18" Semantics="timing"
PhysicalLink="Infotainment_Control_Bus_CAN">
<SHORTNAME>Infotainment_Control_Bus_CAN_TIMEOUT_AX </SHORTNAME>
<LONGNAME>Timeout N_As/N_Ar</LONGNAME>
<DESCRIPTION>Time from transmit request until a CAN frame transmit
confirmation is received.</DESCRIPTION>
</COMPARAM>

In my code i am extracting the data within
<LONGNAME>,which is Timeout N_As/N_Ar.These tags repeat and will have
different timer names..like

- <COMPARAM id="_339" DDORef="_18" Semantics="timing"
PhysicalLink="Infotainment_Control_Bus_CAN">
<SHORTNAME>Infotainment_Control_Bus_CAN_TIMEOUT_BS </SHORTNAME>
<LONGNAME>Timeout N_Bs</LONGNAME>
<DESCRIPTION>Time that the transmitter of a multi-frame message
shall wait to receive a flow control (FC) frame before timing out with
a network layer error.</DESCRIPTION>
</COMPARAM>

I need to remove the words Timeout from the data,and
take only the abbrevation..i.e.N_As/N_bs like that .In short i have to
remove the words which come with name Time,and also the space which
comes next to it.
and take only the abbreviation.Can someone help me in this.
Thanks
Assuming you're naming the string 'logname' and the only space is
between the Time* word and the tags, this should work: logname.split()
[-1]
May 14 '07 #2
In <11*********************@o5g2000hsb.googlegroups.c om>, saif.shakeel
wrote:
Hi,
I am parsing an xml file ,and one part of structure looks
something like this:

- <COMPARAM id="_338" DDORef="_18" Semantics="timing"
PhysicalLink="Infotainment_Control_Bus_CAN">
<SHORTNAME>Infotainment_Control_Bus_CAN_TIMEOUT_AX </SHORTNAME>
<LONGNAME>Timeout N_As/N_Ar</LONGNAME>
<DESCRIPTION>Time from transmit request until a CAN frame transmit
confirmation is received.</DESCRIPTION>
</COMPARAM>

In my code i am extracting the data within
<LONGNAME>,which is Timeout N_As/N_Ar.These tags repeat and will have
different timer names..like

- <COMPARAM id="_339" DDORef="_18" Semantics="timing"
PhysicalLink="Infotainment_Control_Bus_CAN">
<SHORTNAME>Infotainment_Control_Bus_CAN_TIMEOUT_BS </SHORTNAME>
<LONGNAME>Timeout N_Bs</LONGNAME>
<DESCRIPTION>Time that the transmitter of a multi-frame message
shall wait to receive a flow control (FC) frame before timing out with
a network layer error.</DESCRIPTION>
</COMPARAM>

I need to remove the words Timeout from the data,and
take only the abbrevation..i.e.N_As/N_bs like that .In short i have to
remove the words which come with name Time,and also the space which
comes next to it.
and take only the abbreviation.Can someone help me in this.
You can test for the prefix with the `startswith()` method and use string
slicing to create a new string without the prefix:

In [3]: prefix = 'Timeout '

In [4]: longname = 'Timeout N_Bs'

In [5]: longname.startswith(prefix)
Out[5]: True

In [6]: longname = longname[len(prefix):]

In [7]: longname
Out[7]: 'N_Bs'

Ciao,
Marc 'BlackJack' Rintsch
May 14 '07 #3
On May 13, 10:56 pm, saif.shak...@gmail.com wrote:
Hi,
I am parsing an xml file ,and one part of structure looks
something like this:

- <COMPARAM id="_338" DDORef="_18" Semantics="timing"
PhysicalLink="Infotainment_Control_Bus_CAN">
<SHORTNAME>Infotainment_Control_Bus_CAN_TIMEOUT_AX </SHORTNAME>
<LONGNAME>Timeout N_As/N_Ar</LONGNAME>
<DESCRIPTION>Time from transmit request until a CAN frame transmit
confirmation is received.</DESCRIPTION>
</COMPARAM>

In my code i am extracting the data within
<LONGNAME>,which is Timeout N_As/N_Ar.These tags repeat and will have
different timer names..like

- <COMPARAM id="_339" DDORef="_18" Semantics="timing"
PhysicalLink="Infotainment_Control_Bus_CAN">
<SHORTNAME>Infotainment_Control_Bus_CAN_TIMEOUT_BS </SHORTNAME>
<LONGNAME>Timeout N_Bs</LONGNAME>
<DESCRIPTION>Time that the transmitter of a multi-frame message
shall wait to receive a flow control (FC) frame before timing out with
a network layer error.</DESCRIPTION>
</COMPARAM>

I need to remove the words Timeout from the data,and
take only the abbrevation..i.e.N_As/N_bs like that .In short i have to
remove the words which come with name Time,and also the space which
comes next to it.
and take only the abbreviation.Can someone help me in this.
Thanks
Did you get elementtree working?

May 14 '07 #4
On May 14, 1:04 pm, half.ital...@gmail.com wrote:
On May 13, 10:56 pm, saif.shak...@gmail.com wrote:


Hi,
I am parsing an xml file ,and one part of structure looks
something like this:
- <COMPARAM id="_338" DDORef="_18" Semantics="timing"
PhysicalLink="Infotainment_Control_Bus_CAN">
<SHORTNAME>Infotainment_Control_Bus_CAN_TIMEOUT_AX </SHORTNAME>
<LONGNAME>Timeout N_As/N_Ar</LONGNAME>
<DESCRIPTION>Time from transmit request until a CAN frame transmit
confirmation is received.</DESCRIPTION>
</COMPARAM>
In my code i am extracting the data within
<LONGNAME>,which is Timeout N_As/N_Ar.These tags repeat and will have
different timer names..like
- <COMPARAM id="_339" DDORef="_18" Semantics="timing"
PhysicalLink="Infotainment_Control_Bus_CAN">
<SHORTNAME>Infotainment_Control_Bus_CAN_TIMEOUT_BS </SHORTNAME>
<LONGNAME>Timeout N_Bs</LONGNAME>
<DESCRIPTION>Time that the transmitter of a multi-frame message
shall wait to receive a flow control (FC) frame before timing out with
a network layer error.</DESCRIPTION>
</COMPARAM>
I need to remove the words Timeout from the data,and
take only the abbrevation..i.e.N_As/N_bs like that .In short i have to
remove the words which come with name Time,and also the space which
comes next to it.
and take only the abbreviation.Can someone help me in this.
Thanks

Did you get elementtree working?- Hide quoted text -

- Show quoted text -
Thanks for thr replies.It helped a lot.
Regarding the element tree problem,the module error is gone but a new
problem has appeared,which i have posted in new thread,

May 14 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: scott | last post by:
Below, I'm trying to remove the querystring name& value of "catID=12". I mananged to isolate the RESULTS part, but I need to be able to strip the querystring name and it's value, no matter if the...
0
by: sameer mowade via .NET 247 | last post by:
Hello All, I have problem while dynamically removing row from the Datagrid which i have added dynamically as shown in the following code snippet. The problem is that while removing dynamically...
23
by: Peter Row | last post by:
Hi, I am currently working on a VB.NET project that has been going for quite a while. In the past it has been developed with a lot of compatibility VB6 functions and constants, e.g Left(),...
6
by: Niyazi | last post by:
Hi all, What is fastest way removing duplicated value from string array using vb.net? Here is what currently I am doing but the the array contains over 16000 items. And it just do it in 10 or...
6
by: bruce | last post by:
hi... i'm running into a problem where i'm seeing non-ascii chars in the parsing i'm doing. in looking through various docs, i can't find functions to remove/restrict strings to valid ascii...
13
by: Mumia W. | last post by:
Hello all. I have a C++ program that can count the YOYOs that are in a grid of Y's and O's. For example, this Y O Y O O Y O Y O Y O O Y O Y Y O Y O Y O O Y O O Y Y O Y O
11
by: MikeT | last post by:
This may sound very elementary, but can you trap when your object is set to null within the object? I have created a class that registers an event from an object passed in the constructor. When...
8
by: svarc | last post by:
In reference to: How to remove a variable length word from a string I'm trying to use the code you suggested to shalini for extracting a substring from a string...but not able to do so...
11
by: ramu | last post by:
Hi, Suppose I have a string like this: "I have a string \"and a inner string\\\" I want to remove space in this string but not in the inner string" In the above string I have to remove...
4
by: Ahmed, Shakir | last post by:
I need to remove text string from the list of the numbers mentioned below: 080829-7_A 070529-5_c 080824-7_O 070405_6_p The output will be : 080829-7 070529-5
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.