I have a CSV file that looks like this:
Values Dates
10 3/17
20 4/17
40 5/17
My goal is to loop through the "Values" column and find the differences between each row, and as a bonus find the average difference between rows. I am familiar with VBA code for excel, in which I would just use i - (i - 1), but that doesn't translate too well to Python. So far, my code looks like:
import csv
import os
changes = []
os.path.join("Path", "To", "File")
with open(file) as dFile:
reader = csv.reader(dFile)
next(reader)
for row in reader:
change = row[0] - (row-1)[0]
changes.append(change)
I didn't really expect this to work but not sure how to interact with the previous row in a loop. Any ideas?