I have a string with variable length and I want to give a format to strptime
in order for the rest of the string to be ignored. Let me exemplify. I have something like
9/4/2013,00:00:00,7.8,7.4,9.53
10/4/2013,00:00:00,8.64,7.4,9.53
and I want a format that makes the command strptime(line,format)
work to read those lines. Something like format='%d/%m/%Y,%H:%M:%S*'
, although I know that doesn't work. I guess my question is kind of similar to this one, but no answer there could help me and my problem is a little worse because the full length of my string can vary. I have a feeling that dateutil
could solve my problem, but I can't find something there that does the trick.
I can probably do something like strptime(''.join(line.split(',')[:2]),format)
, but I wouldn't want to resort to that for user-related issues.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…