Re: [Tutor] Testing a string to see if it contains a substring (dw)

2015-01-23 Thread Mark Lawrence
On 22/01/2015 15:40, dw wrote: Thanks for your good comments. I do think I found a work around body = "" for x in range(0,len(line_array)): test_line = len(re.findall(r'[0-9]{2}/[0-9]{2}/[0-9]{4}', line_array[x])) if test_line > 0: body = body + line_array[x]+"\n" Using

Re: [Tutor] Testing a string to see if it contains a substring (Steve and Mark)

2015-01-23 Thread Mark Lawrence
On 22/01/2015 16:15, dw wrote: Thanks so much Steve and Mark! You've given me a lot to chew on. :-D I'll pursue! More Python FUN!! Thanks for the thanks, but please don't change the subject as it breaks threading, making it more

Re: [Tutor] Testing a string to see if it contains a substring (dw)

2015-01-23 Thread dw
Thanks for your good comments. I do think I found a work around body = "" for x in range(0,len(line_array)): test_line = len(re.findall(r'[0-9]{2}/[0-9]{2}/[0-9]{4}', line_array[x])) if test_line > 0: body = body + line_array[x]+"\n" For each iteration re.findall returns a lis

Re: [Tutor] Testing a string to see if it contains a substring (Steve and Mark)

2015-01-23 Thread dw
Thanks so much Steve and Mark! You've given me a lot to chew on. :-D I'll pursue! More Python FUN!! Based on your description, I think the best way to do this is: # remove blank lines line_array = [line for line in line_array if l

Re: [Tutor] Testing a string to see if it contains a substring

2015-01-21 Thread Mark Lawrence
On 21/01/2015 18:14, dw wrote: Hello Python Friends. I have a string array, called "line_array". There may be up to 50 or more elements in the array. So: - line_array[1] may contain "01/04/2013 10:43 AM17,410,217 DEV-ALL-01-04-13.rlc\n" - line_array[2] may contain "01/25/2013 03:21 PM

Re: [Tutor] Testing a string to see if it contains a substring

2015-01-21 Thread Danny Yoo
How large will your array be in production? If it going to be very large, you may want to consider a database. You're simulating a collection of records as an in-memory sequence of flat strings. This design won't scale, so if you are working with a lot of data, you may want to look into a dedicat

Re: [Tutor] Testing a string to see if it contains a substring

2015-01-21 Thread Steven D'Aprano
On Wed, Jan 21, 2015 at 10:14:42AM -0800, dw wrote: > Hello Python Friends. > I have a string array, called "line_array". Do you mean a list of strings? "String array" is not a standard Python term, it could mean something from the array module, from numpy, or something completely different. It

Re: [Tutor] Testing a string to see if it contains a substring

2015-01-21 Thread Alan Gauld
On 21/01/15 18:14, dw wrote: - line_array[1] may contain "01/04/2013 10:43 AM17,410,217 DEV-ALL-01-04-13.rlc\n" - line_array[2] may contain "01/25/2013 03:21 PM17,431,230 DEV-ALL-01-25-2013.rlc\n" - line_array[3] may contain "\n" I want to retain all elements which are valid (

[Tutor] Testing a string to see if it contains a substring

2015-01-21 Thread dw
Hello Python Friends. I have a string array, called "line_array". There may be up to 50 or more elements in the array. So: - line_array[1] may contain "01/04/2013 10:43 AM17,410,217 DEV-ALL-01-04-13.rlc\n" - line_array[2] may contain "01/25/2013 03:21 PM17,431,230 DEV-ALL-01-25-2