13

I am totally new into programming, and I am giving a stab to python reading CSV files with Pythin. I am doing this using Spyder. I am getting a the error "module 'datetime' has no attribute 'strptime'", and can't figure it out. Any help will be apppreciated. Here is my code:

import os
import csv
from datetime import datetime

path=csvpath=os.path.join("..","Practice","Google Stock Market Data - 
google_stock_data.csv")
file=open(path,newline="")
reader=csv.reader(file)
header=next(reader)

data=[]      

for row in reader:

date=datetime.strptime(row[0], '%m/%d/%y')

Here is the error message I am getting.

date=datetime.strptime(row[0], '%m/%d/%y')

AttributeError: module 'datetime' has no attribute 'strptime'
Galvarado
  • 141
  • 1
  • 5

1 Answers1

11

try datetime.datetime.strptime()

date = datetime.datetime.strptime(row[0], '%m/%d/%y')

Tim McNaughton
  • 170
  • 2
  • 7