Reading csv and importing into datatable (Python)
Question: New to python,so im reading an excel csv and i want to import the results into
a datatable for use in later code, i.e i want to reference column names in
logic to generate results.

below is my code thus far, the excel reading bit is fine, i left that there to
work on, but i cant get datatables to work i think im missing something simple

I have got easy install in and have setup tools on, i have the webpaste kit
installed but i cant reference it. i also just run `datatables-0.4.9/setup.py`
aswell but am not sure how i need to reference this in my script to begin
working on it.

    
    
    import csv
    import datatables
    with open('Data/ShowroomData.csv', 'rt') as Data:
        SR = csv.reader(Data, delimiter=' ', quotechar='|')
        next(Data)
        for row in SR:
            print (row)
    
    table = DataTable('Data/ShowroomData.csv', 'rt')
    for row in table:
            print (row['SiteName'], row['BGPAS'])
    


Answer: If you want to be able to access the attributes of each row by the column
name, I don't think you need
[`datatables`](https://pypi.python.org/pypi/datatables/0.4.9). All you need is
a [`DictReader` from the `csv` standard library
module](https://docs.python.org/2/library/csv.html#csv.DictReader).

The code would look something like this:

    
    
    import csv
    with open('Data/ShowroomData.csv', 'rt') as Data:
        SR = csv.DictReader(Data, delimiter=' ', quotechar='|')
        for row in SR:
            # if you were to print just `row`, you would get a dictionary
            # like {'SiteName': 'foo', 'BGPAS': 'bar'}
            print (row['SiteName'], row['BGPAS'])
    

