On 03/06/15 21:23, richard kappler wrote:
hold the phone
I have no idea why it worked, would love an explanation, but I changed
my previous test script by eliminating
for tag in (icdm):
This loops over the string assigning the characters i,c,d and m to tag
if 'icdm' in line:
This
On 03/06/15 20:10, richard kappler wrote:
for formatting a string and adding descriptors:
test = 'datetimepart1part2part3the_rest'
If this is really about parsing dates and times have
you looked at the datetime module and its parsing/formatting
functions (ie strptime/strftime)?
Can I stop
I was trying to keep it simple, you'd think by now I'd know better. My
fault and my apology.
It's definitely not all dates and times, the data and character types
vary. This is the output from my log parser script which you helped on the
other day. there are essentially two types of line:
Tue
hold the phone
I have no idea why it worked, would love an explanation, but I changed my
previous test script by eliminating
for tag in (icdm):
and changing
if tag in line
to
if 'icdm' in line:
and it works perfectly! It only iterates over the file once, and the else
executes so both
On 03/06/15 21:13, richard kappler wrote:
I was trying to keep it simple, you'd think by now I'd know better. My
fault and my apology.
It's definitely not all dates and times, the data and character types
vary. This is the output from my log parser script which you helped on
the other day.
figured that out from your last post, and thank you, now I understand how
that works. I thought I was looking for the entire string, not each
character. That bit all makes sense now.
A descriptor is, for example, for the following part of a string '0032.4'
the descriptor would be weight, so the
for formatting a string and adding descriptors:
test = 'datetimepart1part2part3the_rest'
newtest = 'date=' + test[0:4] + ' time=' + test[4:8] + ' part1=' +
test[8:13] + ' part2=' + test[13:18] + ' part3=' + test[18:23] + ' the
rest=' + test[23:]
and while this may be ugly, it does what I want
On 2015-06-03 12:53, Alan Gauld wrote:
...
If this is really about parsing dates and times have
you looked at the datetime module and its parsing/formatting
functions (ie strptime/strftime)?
I asssume strftime gets its name from 'string from time.'
What about strptime? How did that get its
On 03Jun2015 14:16, Alex Kleider aklei...@sonic.net wrote:
On 2015-06-03 12:53, Alan Gauld wrote:
...
If this is really about parsing dates and times have
you looked at the datetime module and its parsing/formatting
functions (ie strptime/strftime)?
I asssume strftime gets its name from
On 2015-06-03 15:13, Mark Lawrence wrote:
'f' for format, 'p' for parse, having originally come from plain old
C. More here
https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior
So I was wrong about the 'f' as well as having no clue about the 'p'!
Thank you very much
Perhaps the better way for me to have asked this question would have been:
How can I find the location within a string of every instance of a
character such as ']'?
regards, Richard
On Wed, Jun 3, 2015 at 5:16 PM, Alex Kleider aklei...@sonic.net wrote:
On 2015-06-03 12:53, Alan Gauld wrote:
On 03/06/2015 22:16, Alex Kleider wrote:
On 2015-06-03 12:53, Alan Gauld wrote:
...
If this is really about parsing dates and times have
you looked at the datetime module and its parsing/formatting
functions (ie strptime/strftime)?
I asssume strftime gets its name from 'string from time.'
On 03/06/15 22:16, Alex Kleider wrote:
On 2015-06-03 12:53, Alan Gauld wrote:
...
If this is really about parsing dates and times have
you looked at the datetime module and its parsing/formatting
functions (ie strptime/strftime)?
I asssume strftime gets its name from 'string from time.'
What
On 03Jun2015 17:35, richard kappler richkapp...@gmail.com wrote:
Perhaps the better way for me to have asked this question would have been:
How can I find the location within a string of every instance of a
character such as ']'?
With the str.find method!
s = 'a]b]c'
pos = s.find(']')
richard kappler wrote:
Perhaps the better way for me to have asked this question would have been:
How can I find the location within a string of every instance of a
character such as ']'?
import re
s = alpha]beta]gamma]delta
[m.start() for m in re.finditer(r], s)]
[5, 10, 16]
But do you
15 matches
Mail list logo