with open(filename, 'r') as csvfile:
csvreader = csv.reader(csvfile)
for row in csvreader:
rows.append(row)
# get total number of rows
print("Total no. of rows: %d" % (csvreader.line_num))
print('\n rows are:\n')
for row in rows[:csvreader.line_num]:
# parsing each column of a row
for col in row:
print("%10s" % col),
print('\n')
def read_rows():
with open("u.dat") as textFile:
rows = [[float(digit) for digit in line.split()] for line in textFile]
return np.array(rows)
rows = read_rows()