python 读取.csv文件中数据的库有两个,一个是csv库,一个是pandas库。

调用读取指令读取数据后得到一个csv对象,想要用numpy等库处理时候,需要对其进行转型。

csv读取

import os

import csv

import matplotlib.pyplot as plt

import numpy as np

data_sourse_dir = "G:\\project\\"

# 遍历数据结果下的所有文件

testids = os.listdir(data_sourse_dir)

fig = plt.figure(1)

legend_name1 = list()

for testid in testids:

if "target_name1" in testid:

real_data_dir = data_sourse_dir + testid + "\\"

testids2 = os.listdir(real_data_dir)

for testid2 in testids2:

if "agcBigScaleStatisticTable" in testid2:

ful_data_dir = real_data_dir + testid2

data_file = open(ful_data_dir,'r')

data = csv.reader(data_file)

counter_max_value = [row[20] for row in data]

counter_max_value = list(map(int,counter_max_value))

plt.plot(counter_max_value)

legend_name1.append(testid)

plt.legend(legend_name1,loc = "upper right")

fig = plt.figure(2)

legend_name2 = []

for testid in testids:

if "target_name2" in testid:

real_data_dir = data_sourse_dir + testid + "\\"

testids2 = os.listdir(real_data_dir)

for testid2 in testids2:

if "agcBigScaleStatisticTable" in testid2:

ful_data_dir = real_data_dir + testid2

data_file = open(ful_data_dir,'r')

data = csv.reader(data_file)

counter_max_value = [row[20] for row in data]

counter_max_value = list(map(int,counter_max_value))

plt.plot(counter_max_value)

legend_name2.append(testid)

plt.legend(legend_name2,loc = "upper right")

fig = plt.figure(3)

legend_name3 = []

for testid in testids:

if "target_name3" in testid:

real_data_dir = data_sourse_dir + testid + "\\"

testids2 = os.listdir(real_data_dir)

for testid2 in testids2:

if "agcBigScaleStatisticTable" in testid2:

ful_data_dir = real_data_dir + testid2

data_file = open(ful_data_dir,'r')

data = csv.reader(data_file)

counter_max_value = [row[20] for row in data]

counter_max_value = list(map(int,counter_max_value))

plt.plot(counter_max_value)

legend_name3.append(testid)

plt.legend(legend_name3,loc = "upper right")

plt.show()

pandas 读取

import pandas as pd

from matplotlib import pyplot as plt

agc_param = pd.read_csv(unit_test_output_dir + test_csv, index_col=None, dtype={'voiceProb': 'float64', 'energyProb': 'float64', 'snr': 'float64', 'firstStageGain': 'float64'})

agc_param.to_numpy()

key = 'target_key_to_be_ploted'

plt.plot(agc_param[key])

plt.show()

python读取csv文件中数据_python读取.csv文件中的数据相关推荐

  1. python csv数据处理生成图_Python 读取CSV文件数据并生成可视化图形

    CSV 文件数据读取并生成图形 CSV 文件格式 在文本文件中存储数据,最简单的方式就是将数据按照一定的格式存放在文件中,在读取文件时根据设计好的格式去将对应数据读取出来,这样就能很方便的进行简单数据 ...

  2. python读取html文件中的表格数据_Python 读取各类文件格式的文本信息 | doc,excel,html,mht...

    原标题:Python 读取各类文件格式的文本信息 | doc,excel,html,mht 众所周知,python最强大的地方在于,python社区汇总拥有丰富的第三方库,开源的特性,使得有越来越多的 ...

  3. python读取csv文件路径设置_python读取csv文件

    1 importcsv2 tsvfile = open('any_different_file/excel2.tsv','rt')3 readers =csv.reader(tsvfile)4 for ...

  4. python读取压缩文件的大小_python查看zip包中文件及大小的方法

    python查看zip包中文件及大小的方法 本文实例讲述了python查看zip包中文件及大小的方法.分享给大家供大家参考.具体实现方法如下: #!/usr/bin/env python import ...

  5. python读取字符串指定位置字符_python读取txt文件中特定位置字符的方法

    python读取txt文件中特定位置字符的方法 如下所示: # -*- coding:utf-8 -*- import sys reload(sys) sys.setdefaultencoding(' ...

  6. python读取两个csv文件后比较_python – 读取两个csv文件并比较每一行.如果行匹配打印两行,如果不相似则打印无效...

    import csv f1 = open("file1.csv") f2 = open("file2.csv") csv_f1 = csv.reader(f1) ...

  7. python生成csv文件带水印_Python从CSV文件导入数据和生成简单图表

    我们已经完成Python的基础环境搭建工作,现在我们尝试导入CSV数据 我们准备一个csv测试数据,文件名是csv-test-data.csv数据. 我们将文件传到Linux上 准备导入的代码 我们运 ...

  8. python中写入csv文件的方法_Python写入CSV文件的方法

    python笔记5-python2写csv文件中文乱码问题 前言 python2最大的坑在于中文编码问题,遇到中文报错首先加u,再各种encode.decode. 当list.tuple.dict里面 ...

  9. python 获取csv的列数_Python读取excel的两种方法

    excel是什么 Microsoft Excel是一个使用非常广泛的电子表格程序.它的用户友好性和吸引人的功能使其成为数据科学中常用的工具.对于excel来说,整个excel文件称为工作簿,工作簿中的 ...

  10. python读取excel内容和写入_Python读取和写入Excel文件

    制作Excel表 常用方法说明 Workbook类 Workbook类创建一个XlswWrite的Workbook对象,相当于创建一个excel表 And_worksheet()用来创建工作表,默认为 ...

最新文章

  1. Android动态加载jar/dex
  2. 激辩:机器究竟能否理解常识?
  3. hive导数据到mysql 自增主键出错_老大问我:“建表为啥还设置个自增 id ?用流水号当主键不正好么?”...
  4. 【SSM框架系列】Spring IoC(控制反转) DI(依赖注入)
  5. 【Qt】QModbusDataUnit类
  6. 小蚂蚁学习C语言(25)——C语言结构体——使用结构体手动录入信息的小案例...
  7. 最近很火的百度MIP之 zblog改造
  8. DoNet 高效开发必备开发工具
  9. arcgis运行慢_ArcGIS Pro运行较慢的诊断方法
  10. SQL Server表和字段说明的增加和更新
  11. 铸造行业ERP管理软件的开发
  12. Java正则表达式工具类(持续更新)
  13. 嵌入式1553B总线开发板的应用
  14. 质量管理三个概念:QC、QA和QM 解析
  15. 优秀自律的人手机上都装了些什么app?看完你就懂了!
  16. 软考2022下半年上午题真题和知识点整理
  17. Unity——用代码实现序列帧动画
  18. 数学不好 学软件测试能学会吗,英语差、数学烂,我还能学好编程吗?
  19. 深入浅出matplotlib(12):椭圆示意图
  20. 计算机专业对应的职业,这十个高薪职业对应哪些大学专业?看完你就明白啦

热门文章

  1. Linux -- 在文件中添加信息的方法(转)
  2. Dubbo框架协议总结
  3. 解决Win7Win8 64位下Source Insight提示未完整安装的问题[转]
  4. shell 截取文件名及扩展名
  5. python网络编程学习笔记(5):socket的一些补充
  6. 冷备份实验,裸设备上备份
  7. AD、DHCP、DNS概念整理
  8. enq: HW - contention等待事件
  9. TFS -- 使用手记 (更新2009/12/3)
  10. 向真正Java高手请教ant构建工具的类装载器问题