trench
trench

Reputation: 5355

Importing Excel .csv to SQLite

I am importing Excel files and csvs to SQLite and the dates are being imported as the Excel float format (41323.11). Can I dictate that they should be imported in a certain format which can easily be viewed when I query? (YYYY-MM-DD HH:MM:SS)

My problem is that I export this data into csv and manipulate it with pandas. I seem to have a lot of trouble getting pandas to recognize that these are really dates.. I have to open the files, reformat the data columns, save, open the file with notepad and save as UTF-8, just to get the date functions to work in pandas.

Upvotes: 0

Views: 168

Answers (1)

user 12321
user 12321

Reputation: 2906

did you try "parse_dates" when importing your CSV? like this:

In [53]: df = pd.read_csv('foo.csv', index_col=0, parse_dates=True) In [54]: df Out[54]: A B C date
2009-01-01 a 1 2 2009-01-02 b 3 4 2009-01-03 c 4 5

Upvotes: 1

Related Questions