Read data from .csv file with Python

Sample code that reads data from .csv file with Python

import csv
csvfile = 'file address'
file_data = open(csvfile, 'rb')
b = csv.reader(file_data)
def read_csv_tolist(filename):
    import csv
    f = filename
    f_open = open(f, 'rb')
    d = csv.reader(f_open)
    data_list = []
    for i in d:
    return data_list     # [row][data] 

def list_to_float(data_list):   # [a, b, c, ...]
    r_list = []
    if data_list[-1] == '\n':
        length = len(data_list)-1
        length = len(data_list)
    for i in range(0, length):
    return r_list

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s