def read_csv_rows(path):
"""
Extract the rows from the CSV at the specified path.
Will throw an error if the file doesn't exist.
:type path: string
:rtype: list[list[string]]
"""
with open(path, 'rU') as infile:
reader = csv.reader(infile, delimiter=',')
rows = [row for row in reader]
# eliminate trailing cols that have no entries (CSI-215)
for idx, row in enumerate(rows):
clipIndex = 0
for col in row[::-1]:
if not col:
clipIndex -= 1
else:
break
if clipIndex < 0:
rows[idx] = rows[idx][:clipIndex]
return rows
评论列表
文章目录