python读取data_Python DataFile包_程序模块 - PyPI - 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”])

欢迎加入QQ群-->: 979659372

group.png

推荐PyPI第三方库

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值