python - 使用 csv2rec 时 python 中的 matplotlib 库出错

标签 python csv numpy matplotlib ipython

我正在 Ipython 中工作,尝试加载 csv 文件。

from matplotlib import *
data=matplotlib.mlab.csv2rec('helix.csv',delimiter='\t')

这是错误消息

IOError                                   Traceback (most recent call last)
/mnt/hgfs/docs/python/<ipython console> in <module>()
/usr/lib/pymodules/python2.7/matplotlib/mlab.pyc in csv2rec(fname, comments, skiprows, checkrows, delimiter, converterd, names, missing, missingd, use_mrecords)
   2125 
   2126     # reset the reader and start over
-> 2127     fh.seek(0)
   2128     reader = csv.reader(fh, delimiter=delimiter)
   2129     process_skiprows(reader)      
IOError: [Errno 29] Illegal seek

有人已经遇到这个错误了吗?我尝试重新安装所有内容,我正在使用 Python2.7,并且有 Matplotlib v0.99.3、Numpy v1.5.1、Ipython0.10.1

最佳答案

我尝试使用此文件:

snp1,snp2,snp3
A,A,A
A,B,A
B,B,B

这是结果:

In [3]: csv2rec('helix.csv')
Out[3]: 
rec.array([('A', 'A', 'A'), ('A', 'B', 'A'), ('B', 'B', 'B')], 
      dtype=[('snp1', '|S1'), ('snp2', '|S1'), ('snp3', '|S1')])

我有 matplotlib 1.0.1,所以你可以尝试更新它,我无法访问较旧的 matplotlib 进行测试。

关于python - 使用 csv2rec 时 python 中的 matplotlib 库出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7532270/

相关文章:

python - 有选择地删除 pandas 数据框中已弃用的行

csv - 导入 csv 在 Jupyter 笔记本中的初始位置 Julia 中返回编码标识符

windows - 如何批量读取 CSV 文件特定列中的值?

python - pandas dataframe无法获取值

python - Python 模型的 Google Cloud Datastore 真实世界示例

python - 如何在列表中找到最接近的值,其中 x > numpy 数组中每个值的值而不循环

python - 如何将包含多个值和逗号的变量写入 csv 文件?

python - 获取 numpy 数组中项目的索引,其中值在列表中

python - python中 "for loop"的步骤

python - <U12 是什么类型?