How can I get the data from the CSV file and declare a variable for each column using python?
Question: I have a csv file that might look like this (contents variable-format not):

"Red","House","1/1/2010","Green Eggs and Ham",1,10

The csv file that will always have just one row of data and 6 columns

How can I get the data from the cvs file and declare a variable for each
column value using python?

ie.

var1 = Column1

Var2 = Column2

var3 = Column3

etc.

so that when I type "print var3", the following value would appear.

"1/1/2010"

I thought the following would work but I got an error message saying
NameError: name var3 is not defined.

    
    
    f = csv.reader(open("C:\Test\Test.csv", "rb"))
    
    for row in f:
        var1, var2, var3, var4, var5, var6 = row
    
    print var3
    

I need to use these values later on the script. Ideas anyone. Super new to
this. Python 2.7


Answer: Each row is treated as a list in Python. So, if 'line' contains your 6
elements, 'line[0]' is your first column element.

Also, I changed the 'rt' to 'r' as I was getting some other sort of error, but
try this:

    
    
    import csv
    with open('C:\\test.csv', 'r') as csvfile:
    f = csv.reader(csvfile)
    for line in f:
        print (line[2])
    

