Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to sum a column in csv python using list in python

import csv
csv_file = csv.reader(open("your_file_name.csv"))

dist = 0
for row in csv_file:
    _dist = row[2]
    try: 
        _dist = float(_dist)
    except ValueError:
        _dist = 0

    dist += _dist
Comment

PREVIOUS NEXT
Code Example
Python :: print greeting in python explication 
Python :: Python program to remove newline characters from a file 
Python :: pygame do you need to use int() for positions 
Python :: numpy print full array to srdout 
Python :: python - from most_similar to ldictionary 
Python :: tf.data.Dataset select files with labels filter 
Python :: plt.savefig no frame 
Python :: print class name python 
Python :: Reading from a file way02 
Python :: max value from multiple columns pandas 
Python :: python multiple imports 
Python :: scapy get packet destination port python 
Python :: Python match.span() 
Python :: change the Values to Numpy Array 
Python :: json to csv python github 
Python :: disable kivy button in kv 
Python :: bs4 check element type 
Python :: pypy stragger 
Python :: stripe white space django template 
Python :: convert to category data type 
Python :: csv/gpd to shapefile python 
Python :: Python Code for Checking if a number is an Odd number 
Python :: how to prefix numbers with zero in python 
Python :: for con condicion 
Python :: How to Move and Delete Files in Python 
Python :: python multi arguments 
Python :: lists as parameters in stats.f_oneway 
Python :: python print top 5 results of array 
Python :: hwoto neglect if any exception happening in python 
Python :: make_interp_spline 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =