Re: [Tutor] list comprehension, testing for multiple conditions

2012-08-21 Thread Johann Spies
#start import re exclude = re.compile('vn|vt|^$|^#') fileName = '/tmp/x' theFileOpened = open(fileName,'r') theTextAsList = theFileOpened.readlines() theTextAsListStripped = [] for aLine in theTextAsList: theTextAsListStripped.append

[Tutor] list comprehension, testing for multiple conditions

2012-08-21 Thread Pete O'Connell
Hi I am trying to parse a text file and create a list of all the lines that don't include: "vn", "vt" or are empty. I want to make this as fast as possible because I will be parsing many files each containing thousands of lines. I though I would give list comprehensions a try. The last 3 lines of t

[Tutor] subprocess.Popen help

2012-08-21 Thread Ray Jones
Does anyone know of a link to a really good tutorial that would help me with subprocess.Popen? a tutorial that uses really small words and more examples than explanation? After 15 years of scripting, I'm ashamed to say that I'm still not all that familiar with input, output, pipes, etc. much beyon

Re: [Tutor] extract date and time from string

2012-08-21 Thread Norman Khine
ok, i figured it out: >>> from BeautifulSoup import BeautifulSoup >>> for EVENT in TABLE_CONTENT: ... for index, item in enumerate(EVENT): ... if index == 4: ... soup = BeautifulSoup(item) ... for a in soup.findAll('a'): ...

[Tutor] extract date and time from string

2012-08-21 Thread Norman Khine
Hello, When I try this, I get the following error: ☹ python * master 697cedfitools" Python 2.7.2 (default, Jan 28 2012, 14:53:22) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import dateutil.parser as dpars

Re: [Tutor] Python doubt

2012-08-21 Thread Walter Prins
Hello Akarsh, Welcome to the Python tutor list. On 21 August 2012 13:29, akarsh a wrote: > sir, > How to read an excel file row by row and write each row to different > text files? > ie, if i have an excel file consists of m raw and n columns as follws > 1 as mmm 1525 cv 10.2 >

[Tutor] Python doubt

2012-08-21 Thread akarsh a
sir, How to read an excel file row by row and write each row to different text files? ie, if i have an excel file consists of m raw and n columns as follws 1 as mmm 1525 cv 10.2 2 xv fvbgd 1411 dc 12.5 .. I want to read ea

Re: [Tutor] Error in apparently correct code

2012-08-21 Thread eryksun
On Mon, Aug 20, 2012 at 11:21 PM, Steven D'Aprano wrote: > > Indentation has meaning in Python. When you send email, if your email > program (possibly GMail?) mangles the indentation, your code will become > invalid, unreadable mess. You need to fix this. Often the easiest way to fix > this is to

Re: [Tutor] Escaping globs for glob.iglob()

2012-08-21 Thread Ray Jones
On 08/21/2012 12:59 AM, Alan Gauld wrote: > On 21/08/12 06:42, Ray Jones wrote: > >>Files = glob.iglob(os.path.join(znDir, '*')) >>print Files >> >>for moveFile in Files: >> print moveFile >> >> Nothing happens. The 'print...moveFile' never happens, even though print >> Files shows

Re: [Tutor] Escaping globs for glob.iglob()

2012-08-21 Thread Alan Gauld
On 21/08/12 06:42, Ray Jones wrote: Files = glob.iglob(os.path.join(znDir, '*')) print Files for moveFile in Files: print moveFile Nothing happens. The 'print...moveFile' never happens, even though print Files shows it to be an iglob generator object. Good but does it contain a

Re: [Tutor] Tutor Digest, Vol 102, Issue 48

2012-08-21 Thread Alan Gauld
On 21/08/12 06:12, Osemeka Osuagwu wrote: right_product(row, col) for (row = 0, col = 18) I had anticipated this and added the "if col>len(data[row])-3:" statement But because of zero indexing you need this to be either: if col >= len(data[row])-3: or if col > len(data[row])-4: ie. if row