On Dec 21, 2:01 am, Alexander Kapps wrote:
> On 20.12.2011 22:04, Nick Dokos wrote:
>
>
>
>
>
>
>
>
>
> >>> I have a text file containing such data ;
>
> >>> A B C
> >>> ---
> >>> -2.0100e-01 8.000e-02
On 20.12.2011 22:04, Nick Dokos wrote:
I have a text file containing such data ;
ABC
---
-2.0100e-018.000e-028.000e-05
-2.e-010.000e+00 4.800e-04
-1.9900e-014.000e-021.600e-04
Jérôme wrote:
> Tue, 20 Dec 2011 11:17:15 -0800 (PST)
> Yigit Turgut a écrit:
>
> > Hi all,
> >
> > I have a text file containing such data ;
> >
> > ABC
> > ---
> > -2.0100e-018.000e-028.000e-0
Tue, 20 Dec 2011 11:17:15 -0800 (PST)
Yigit Turgut a écrit:
> Hi all,
>
> I have a text file containing such data ;
>
> ABC
> ---
> -2.0100e-018.000e-028.000e-05
> -2.e-010.000e+00 4.800
On 12/20/2011 02:17 PM, Yigit Turgut wrote:
Hi all,
I have a text file containing such data ;
ABC
---
-2.0100e-018.000e-028.000e-05
-2.e-010.000e+00 4.800e-04
-1.9900e-014.000e-02
Thanks Black Jack
Working
--
http://mail.python.org/mailman/listinfo/python-list
On Sep 25, 9:51 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> I have string like follow
> 12560/ABC,12567/BC,123,567,890/JK
>
> I want above string to group like as follow
> (12560,ABC)
> (12567,BC)
> (123,567,890,JK)
>
> i try regular expression i am able to get first two not the third one.
On Sep 25, 6:34 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> On Thu, 25 Sep 2008 15:51:28 +0100, [EMAIL PROTECTED] wrote:
> > I have string like follow
> > 12560/ABC,12567/BC,123,567,890/JK
>
> > I want above string to group like as follow (12560,ABC)
> > (12567,BC)
> > (123,567,890,JK
You can do it with regexps too :
>--
import re
to_watch = re.compile(r"(?P\d+)[/](?P[A-Z]+)")
final_list = to_watch.findall("12560/ABC,12567/BC,123,567,890/JK")
for number,word in final_list :
print "number:%s -- word: %s"%(num
On Thu, 25 Sep 2008 15:51:28 +0100, [EMAIL PROTECTED] wrote:
> I have string like follow
> 12560/ABC,12567/BC,123,567,890/JK
>
> I want above string to group like as follow (12560,ABC)
> (12567,BC)
> (123,567,890,JK)
>
> i try regular expression i am able to get first two not the third one.
> ca
On Sep 7, 3:50 am, George Sakkis <[EMAIL PROTECTED]> wrote:
> On Sep 5, 5:17 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:
> If this was a code golf challenge,
I'd choose the Unix split solution and be both maintainable as well as
concise :-)
- Paddy.
--
http://mail.python.org/mailman/li
On Sep 5, 5:17 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> On Sep 5, 1:28 pm, Paddy <[EMAIL PROTECTED]> wrote:
>
> > On Sep 5, 5:13 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> > wrote:
>
> > > I have a text source file of about 20.000 lines.>From this file, I like
> > > to write the fir
Shawn Milochik wrote:
> On 9/5/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>> I have a text source file of about 20.000 lines.
>> >From this file, I like to write the first 5 lines to a new file. Close
>> that file, grab the next 5 lines write these to a new file... grabbing
>> 5 lines and cre
Here's my solution, for what it's worth:
#!/usr/bin/env python
import os
input = open("test.txt", "r")
counter = 0
fileNum = 0
fileName = ""
def newFileName():
global fileNum, fileName
while os.path.exists(fileName) or fileName == "":
fileNum += 1
x = "%0.5d" % fileN
[EMAIL PROTECTED] escribió:
> I am still wondering how to do this efficiently in Python (being kind
> of new to it... and it's not for homework).
You should post some code anyway, it would be easier to give useful advice (it
would also demonstrate that you put some effort on it).
Anyway, here i
> Thanks for making me aware of the (UNIX) split command (split -l 5
> inFile.txt), it's short, it's fast, it's beautiful.
>
> I am still wondering how to do this efficiently in Python (being kind
> of new to it... and it's not for homework).
Something like this should do the job:
def nlines(num
On Sep 6, 12:46 am, Steve Holden <[EMAIL PROTECTED]> wrote:
> Arnaud Delobelle wrote:
[...]
> > print "all done!" # All done
> > print "Now there are 4000 files in this directory..."
>
> > Python 3.0 - ready (I've used open() instead of file())
>
> bzzt!
>
> Python 3.0a1 (py3k:57844, Aug 31
and u can
parse lines from read buffer freely.
have fun!
- Original Message -
From: "Shawn Milochik" <[EMAIL PROTECTED]>
To:
Sent: Thursday, September 06, 2007 1:03 AM
Subject: Re: Text processing and file creation
> On 9/5/07, [EMAIL PROTECTED] <[EMAIL PROTECTE
Arnaud Delobelle wrote:
[...]
> from my_useful_functions import new_file, write_first_5_lines,
> done_processing_file, grab_next_5_lines, another_new_file, write_these
>
> in_f = open('myfile')
> out_f = new_file()
> write_first_5_lines(in_f, out_f) # write first 5 lines
> close(out_f)
> while not
On Sep 5, 5:13 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> I have a text source file of about 20.000 lines.>From this file, I like to
> write the first 5 lines to a new file. Close
>
> that file, grab the next 5 lines write these to a new file... grabbing
> 5 lines and creating new files
On Sep 5, 1:28 pm, Paddy <[EMAIL PROTECTED]> wrote:
> On Sep 5, 5:13 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:
>
> > I have a text source file of about 20.000 lines.>From this file, I like to
> > write the first 5 lines to a new file. Close
>
> > that file, grab the next 5 lines write t
On Sep 5, 5:13 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> I have a text source file of about 20.000 lines.>From this file, I like to
> write the first 5 lines to a new file. Close
>
> that file, grab the next 5 lines write these to a new file... grabbing
> 5 lines and creating new files
[EMAIL PROTECTED] wrote:
> I have a text source file of about 20.000 lines.
>>From this file, I like to write the first 5 lines to a new file. Close
> that file, grab the next 5 lines write these to a new file... grabbing
> 5 lines and creating new files until processing of all 20.000 lines is
> do
On Sep 5, 11:57 am, Bjoern Schliessmann wrote:
> [EMAIL PROTECTED] wrote:
> > I would use a counter in a for loop using the readline method to
> > iterate over the 20,000 line file.
>
> file objects are iterables themselves, so there's no need to do that
> by using a method.
Very true! Darn it!
On 9/5/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> I have a text source file of about 20.000 lines.
> >From this file, I like to write the first 5 lines to a new file. Close
> that file, grab the next 5 lines write these to a new file... grabbing
> 5 lines and creating new files until proces
[EMAIL PROTECTED] wrote:
> I would use a counter in a for loop using the readline method to
> iterate over the 20,000 line file.
file objects are iterables themselves, so there's no need to do that
by using a method.
> Reset the counter every 5 lines/ iterations and close the file.
I'd use a
[EMAIL PROTECTED] escribió:
> I have a text source file of about 20.000 lines.
>>From this file, I like to write the first 5 lines to a new file. Close
> that file, grab the next 5 lines write these to a new file... grabbing
> 5 lines and creating new files until processing of all 20.000 lines is
On Sep 5, 11:13 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> I have a text source file of about 20.000 lines.>From this file, I like to
> write the first 5 lines to a new file. Close
>
> that file, grab the next 5 lines write these to a new file... grabbing
> 5 lines and creating new files
Maurice LING wrote:
I'm looking for a way to do this: I need to scan a text (paragraph or
so) and look for occurrences of " ()". That is, if the
text just before the open bracket is the same as the text in the
brackets, then I have to delete the brackets, with the text in it.
How's this?
import
Maurice LING wrote:
> Matt wrote:
> > I'd HIGHLY suggest purchasing the excellent > href="http://www.oreilly.com/catalog/regex2/index.html";>Mastering
> > Regular Expressions by Jeff Friedl. Although it's mostly
geared
> > towards Perl, it will answer all your questions about regular
> > express
Maurice -
Here is a pyparsing treatment of your problem. It is certainly more
verbose, but hopefully easier to follow and later maintain (modifying
valid word characters, for instance). pyparsing implicitly ignores
whitespace, so tabs and newlines within the expression are easily
skipped, withou
Matt wrote:
I'd HIGHLY suggest purchasing the excellent http://www.oreilly.com/catalog/regex2/index.html";>Mastering
Regular Expressions by Jeff Friedl. Although it's mostly geared
towards Perl, it will answer all your questions about regular
expressions. If you're going to work with regexs, this
Maurice LING wrote:
> Matt wrote:
> >
> >
> > Try this:
> > import re
> > my_expr = re.compile(r'(\w+) (\(\1\))')
> > s = "this is (is) a test"
> > print my_expr.sub(r'\1', s)
> > #prints 'this is a test'
> >
> > M@
> >
>
> Thank you Matt. It works out well. The only think that gives it
problem
>
Matt wrote:
Try this:
import re
my_expr = re.compile(r'(\w+) (\(\1\))')
s = "this is (is) a test"
print my_expr.sub(r'\1', s)
#prints 'this is a test'
M@
Thank you Matt. It works out well. The only think that gives it problem
is in events as "there (there)", where between the word and the same
Maurice LING wrote:
> Hi,
>
> I'm looking for a way to do this: I need to scan a text (paragraph or
> so) and look for occurrences of " ()". That is, if
the
> text just before the open bracket is the same as the text in the
> brackets, then I have to delete the brackets, with the text in it.
>
>
35 matches
Mail list logo