On 02/03/2015 12:25, Fabien wrote:
On 02.03.2015 12:55, greymausg wrote:
I have a csv file, the first item on a line is the date in the format
2015-03-02 I try to get that as a date by date(row[0]), but it barfs,
replying "Expecting an integer". (I am really trying to get the offset
in weeks from that date to today())
Have you tried Pandas? http://pandas.pydata.org/
If your csv file has no other problems, the following should do the trick:
import pandas as pd
df = pd.read_csv('file.csv', index_col=0, parse_dates= {"time" : [0]})
Cheers,
Fabien
IMHO complete overkill. Give me the Steven D'Aprano solution any day of
the week.
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
--
https://mail.python.org/mailman/listinfo/python-list