读取数据文件的简单方法

DataFile的Python项目详细描述


此包提供了打开数据文件的简单方法 通过返回对应于 如果列包含字符串,则返回字符串数组。

默认情况下,它将尝试从注释中猜测索引,如果失败,则将索引它。 从0到n:

#!/usr/bin/env python

from datafile.extractfile import dataFile

f = dataFile("./datafile/test/testdocfile.txt")
# the index will be guessed and if not found it will
# be indexed from 0 to n

f = dataFile("./datafile/test/testdocfile.txt",index="auto")
#f will be indexed from 0 to n

#f["0"] will return a numpy array of the first column.
#f["0",1] will return a numpy array of the index number 1 of the first column,
# if the column is divided in index (ensemble of points separated by one or more space)

f = dataFile("./datafile/test/testdocfile.txt" , "A B C D")
#f will be indexed on "A" "B" "C" (if three columns)
f = dataFile("./datafile/test/testdocfile.txt" , ["A", "B","C","D"]
#f will be indexed on "A" "B" "C"

猜测

如果数据文件在注释中包含如下行: #长x(nm)y(nm)d(a) 文件在三列,它将索引这三列 使用“lx(nm)”“ly(nm)”,“d(a)”:

#!/usr/bin/env python
f = dataFile("./file")
f["Lx"]
f["x"]
#both are going to return the first column
f["nm"]
#will return a key error

主要用途

我将它与ipython一起用于绘制数据并探索它们。 发射伊普顿-Pylab将发射伊普顿 matplotlib已加载。 在用数据文件加载文件后,您可以打印数据 只有类型图(f[“a”]、f[“b”])

电子邮件:jeanmichel.arbona@gmail.com

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Springboot数据JPA findByDate()   java是否可以有多个顶级树节点?   javahibernatehql。子查询中的多个   使用Twilio验证java Keyclope电话号码   java重写对象的toString()表示返回意外的符号   java Android最多每15分钟调用一个方法,否则使用保存的数据   在java swing中突出显示jeditorpane中的一些单词   java将时间戳转换为UTC时区   由于main中存在ArrayIndexOutOfBoundsException,导致java编译错误   java如何通过requestscope获取对象内部对象的值?   java访问安卓代码内的网站并检索生成的图像   java这种日期格式的模式是什么?   java解析包含超链接的xml字符串