How can I read in csv files with columns as variable names in Python?
you need to first extract your first row I suggest to count the characters of first row and use this code to read them
f = open("demofile.txt", "r")
print(f.read(5))#put your desired counted charactor inside f.read(n)
when you successfully read it save it on variable and after saving use regex to split them with respect to ","
import re
txt = "The rain in Spain"
x = re.split("[,]", txt, 1)
print(x)
after that use dictionary methods to attain your desired result.
This is a Python question. I have a csv file and would like to read that in. The first row in the file are strings and I would like to use them as variable names. The other rows are integers and I would like them to be a vector of the name of the respective variable.
Thanks,
Tim