0

I am trying to write code in which I have two variables in python code "D" and "T". I want to assign each variable the set of values of respective csv file columns "Data" and "Target". If each column contains 100 values the variable should read 100 value every time. But I can't get the idea how to do so?

with open('dataML.csv') as f:
    reader = csv.reader(f, delimiter=';')
    for row in reader:
        D = row['data']
        T = row['target']
        D.append(data)
        T.append(target)
  • Please show some relevant code. Currently, it's hard to understand what you're asking – sshashank124 Jan 12 '20 at 11:26
  • i have added code. – Smartvision Jan 12 '20 at 11:34
  • Unless you are *specifically* asking about how to solve a cross-version compatibility problem (in which case your question should obviously describe that problem) you should not mix the [tag:python-2.7] and [tag:python-3.x] tags. – tripleee Jan 12 '20 at 11:43
  • You can't read the value into a scalar and then `append` to the same variable as if it were a list. Use two separate variables. – tripleee Jan 12 '20 at 12:05

0 Answers0