从CSV文件导入数据
程序员文章站
2024-02-10 22:16:16
...
import csv
filename = 'D:\CSV\AssetsImportCompleteSample.csv'
data=[]
try:
with open(filename) as f:
reader = csv.reader(f)
header = next(reader)
data=[row for row in reader]
except csv.Error as e:
print("Error reading CSV file at line:%s,%s",reader.line_num,e)
sys.exit(-1)
if header:
print(header)
print('========================')
for datarow in data:
print(datarow)
下一篇: 六大常用布局总结