有没有大神知道怎么导入csv文件数据到基于HTML写的echarts中的
1条回答 默认 最新
关注 # -*- coding: utf-8 -*- """ Created on Wed Oct 17 14:52:50 2018 @author: sofeien """ import os import re path= os.path.abspath('散点图.csv') data_str='var data=[' with open(path,'r',encoding='utf-8') as f_input: line_index=0 for line in f_input: if(line_index==0): line_index+=1 continue list_line=[x.strip() for x in re.split('[,\s]',line)] data_str += "[%s,%s,'%s']," % (list_line[1],list_line[2],list_line[0]) data_str = data_str[:-1]+'];' os.rename('scatter-weight.html', 'scatter-weight_bak.html') with open('scatter-weight_bak.html','r',encoding='utf-8') as f: with open('scatter-weight.html','w',encoding='utf-8') as f_output: for line in f: if(line.find('var data=[')!=-1): f_output.write(data_str) f_output.write('\n') else: f_output.write(line) os.remove('scatter-weight_bak.html')
解决 无用评论 打赏 举报
悬赏问题
- ¥66 换电脑后应用程序报错
- ¥50 array数据同步问题
- ¥15 pic16F877a单片机的外部触发中断程序仿真失效
- ¥15 Matlab插值拟合差分微分规划图论
- ¥15 keil5 target not created
- ¥15 C/C++数据与算法请教
- ¥15 怎么找志同道合的伙伴
- ¥20 如何让程序ab.eXe自已删除干净硬盘里的本文件自己的ab.eXe文件
- ¥50 爬虫预算充足,跪巨佬
- ¥15 滑块验证码拖动问题悬赏