Is it possible to read csv files in columns instead of rows in python?
e.g. if i have a csv file like this:
a b c 1 0 1 1 4 1
How woul
You can use something like this:
# Open file and read lines
input_file = open('filename.csv')
lines = input_file.readlines()
# Create list with n sublists (n - number of columns)
l = [[] for _ in lines[0].split('\t')]
# Fill in sublists
for line in lines:
for i, column in enumerate(line.split('\t')):
l[i].append(column)