I think perl is less fussy about automatic type conversions, isn't it? Haven't done much with perl, but I got that impression, anyway.
Heh, I got atoi from an O'Reilly Python book I bought in 1999 and just got around to reading last week :)
Thanks to bvdet for the strptime examples, looks useful....
User Profile
Collapse
-
Hrrmph. This morning the magic is gone and I get a string in d, just like you did. Last night I was running the code in a live python session and I obviously did something I can't remember now :(
Today I got the job done with this code instead:
...Code:for lines in f: d,t,o,h,l,c,v = lines.split(',') yr,mo,day = d.split('.') if datetime.date(string.atoi(yr),string.atoi(mo),string.atoi(day)).weekday()Leave a comment:
-
Character string wind up as a datetime.date object?
I'm writing a very simple python program to read in an ascii csv file with multiple records formatted like this:
"2010.3.13, 0.0.0, 10.1, 12.2, 9.9, 10.1, 2500" # i.e. a list of daily stock prices with date,time,open, high,low,close, volume fields
I use this python code to read each line from the ascii file named f:
for line in f: d,t,o,h,l,c,v = line.split(',') # where d stands for date, etc
...
No activity results to display
Show More
Leave a comment: