I have a CSV file I want to import and sum the second field, "Revenue". This is my current code that I pieced together from other posts, but can't get it to work. Any help would be greatly appreciated!
Error Types:
- ValueError: invalid literal for int() with base 10: ''
- The total is incorrect. For example, if the numbers were simplified and it read: 10, 20, 30, 40. Instead of sum = 100 it would say sum = 10
Code:
import csv
import pandas as pd
f = open('Sample Data.csv')
f.next() #Skip record 1 aka header row
total = 0
for row in f:
total += int(row[[1]])
print total