473,320 Members | 2,112 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,320 software developers and data experts.

parsing a file name

I have a filename
cairo-2.3.4.src.rpm
Is there any way i can only get 2.3.4 from this file name
thanks

Jan 12 '07 #1
4 1775
On 12 Jan 2007 09:16:51 -0800, CSUIDL PROGRAMMEr <sy*********@yahoo.comwrote:
I have a filename
cairo-2.3.4.src.rpm
Is there any way i can only get 2.3.4 from this file name
thanks

--
http://mail.python.org/mailman/listinfo/python-list
I'm trying to think of a good reason to extract the version from the
filename instead of using RPM to get the real version from the
metadata and I can't come up with one.
Jan 12 '07 #2
Chris Mellon wrote:
>
I'm trying to think of a good reason to extract the version from the
filename instead of using RPM to get the real version from the
metadata and I can't come up with one.
The inquirer doesn't have any RPM handling tools installed/available or
is dealing with a lot of versioned filenames which might be a selection
of different, arbitrary formats.

Try harder! ;-)

Paul

Jan 12 '07 #3
On 12 Jan 2007 10:23:41 -0800, Paul Boddie <pa**@boddie.org.ukwrote:
Chris Mellon wrote:

I'm trying to think of a good reason to extract the version from the
filename instead of using RPM to get the real version from the
metadata and I can't come up with one.

The inquirer doesn't have any RPM handling tools installed/available or
is dealing with a lot of versioned filenames which might be a selection
of different, arbitrary formats.

Try harder! ;-)

Paul
Well, the answer to the first is "get some", so that's not a good
reason. And the second would mean that they asked a question on c.l.p
without giving all the background information on the task they were
doing, and we know that never happens.
Jan 12 '07 #4
CSUIDL PROGRAMMEr wrote:
I have a filename
cairo-2.3.4.src.rpm
Is there any way i can only get 2.3.4 from this file name
>>a = "cairo-2.3.4.src.rpm"
import re
re.compile(r"\d+([.]\d+)*").search(a).group(0)
'2.3.4'
>>a.split("-")[-1][:-len(".src.rpm")]
'2.3.4'
>>".".join(map(str, range(2, 5)))
'2.3.4'

--
Roberto Bonvallet
Jan 12 '07 #5

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

Similar topics

3
by: Willem Ligtenberg | last post by:
I decided to use SAX to parse my xml file. But the parser crashes on: File "/usr/lib/python2.3/site-packages/_xmlplus/sax/handler.py", line 38, in fatalError raise exception...
4
by: Rick Walsh | last post by:
I have an HTML table in the following format: <table> <tr><td>Header 1</td><td>Header 2</td></tr> <tr><td>1</td><td>2</td></tr> <tr><td>3</td><td>4</td></tr> <tr><td>5</td><td>6</td></tr>...
0
by: bruce | last post by:
hi... it appears that i'm running into a possible problem with mechanize/browser/python rgarding the "select_form" method. i've tried the following and get the error listed: br.select_form(nr...
3
by: Anup Daware | last post by:
Hi Group, I am facing a strange problem here: I am trying to read xml response from a servlet using XmlTextWriter. I am able to read the read half of the xml and suddenly an exception:...
4
by: R Wood | last post by:
Greetings - A recent Perl experiment hasn't turned out so well, which has piqued my interest in Python. The project is this: take a Vcard file exported from Apple's Addressbook and use a...
5
by: amjadcsu | last post by:
I am a newbie in python I am trying to parse a xml file and write its content in a txt file. The txt contains null elements. Any reason what iam doing wrong here Here is the code that i wrote...
2
by: python | last post by:
I'm parsing a text file for a proprietary product that has the following 2 directives: #include <somefile> #define <name<value> Defined constants are referenced via <#name#syntax. I'm...
3
by: raghudr | last post by:
Hi all, I am parsing a .xml file.My main intention is to retrieve the name value of node "Signal":- "Name Value" which is "rag". i want to store only the <signal"name value" that is only...
3
by: GazK | last post by:
I have been using an xml parsing script to parse a number of rss feeds and return relevant results to a database. The script has worked well for a couple of years, despite having very crude...
2
by: Felipe De Bene | last post by:
I'm having problems parsing an HTML file with the following syntax : <TABLE cellspacing=0 cellpadding=0 ALIGN=CENTER BORDER=1 width='100%'> <TH BGCOLOR='#c0c0c0' Width='3%'>User ID</TH> <TH...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
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...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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...

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.