csv数据的读取和写入,以及好看的可视化
参考:
https://www.jianshu.com/p/5511cb3bdbb1
https://www.cnblogs.com/cloud-ken/p/8432999.html
https://www.cnblogs.com/unnameable/p/7366437.html
写入csv
import csv
写入csv
line1=['Patients','Age']
c01= ['01',23]
c02 = ['02',24]
out=open('each.csv','a',newline='')
csv_write=csv.writer(out,dialect='excel')
csv_write.writerow(line1)
csv_write.writerow(c01)
csv_write.writerow(c02)
print ("write over")
读取CSV
csv_file=csv.reader(open('each.csv','r'))
print(csv_file)
for line in csv_file:
print(line)
此外,还可以使用pandas读取csv