python - How to read csv file with date as one of the data? -


these data both in excel , in csv files:

date,time,product_type 2015-01-02,02:29:45 pm,cards

i've tried code below , works excel file not in csv file.

import numpy np import pandas pd  df = pd.read_excel('file.xlsx') print(df.head()) 

my code in reading csv file same above code getting error. please help.

import numpy np import pandas pd import datetime  df = pd.read_csv('file.csv', index_col='date', parse_dates=true) print(df.head()) 

error message: unicodedecodeerror: 'utf-8' codec can't decode byte 0xa4 in position 2: invalid start byte

i'm not sure plan data once pulled file if need different format or let me know.

i'm assuming you'll working csv code. code below opens file , every line, splits commas, , appends list (each index being line of code) organization.

file = open("filename.csv","r")  data = [] lines in file:     data.append([lines.split(",")]) '[[date,time,product type, date,time,cards],[date2,,,],,,] 

Comments