Skip to main content

用于组织、记录和验证科学研究中感兴趣的变量的工具

项目描述

主文件

DOI

用于组织、记录和验证科学研究中感兴趣的变量的工具

命令行使用

masterfile --help将列出所有子命令。

创造

masterfile create masterfile_path out_file

加入

masterfile join masterfile_path out_file

提炼

masterfile extract [-s|--skip ROWS] [--index_column COL]
                      masterfile_path csv_file out_file

证实

asterfile validate masterfile_path [file [file ...]]

草案 API 使用示例

import masterfile
# Load all of the .csv files from /path, and the dictionary files in
# /path/dictionaries. Takes settings info from a 'settings.json' file in
# /path.
# joins the .csv files on 'participant_id', which will be used as the index
# There will be warnings if the data look bad in some way
mf = masterfile.load('/path')
# Get the pandas dataframe associated
df = mf.dataframe  # aliased as mf.df

# All the variable stuff is less important, people can go look in data dicts
# So we'll write that stuff later.
v = mf.lookup('sr_t1_panas_pa')
v.contacts # list_of_names
v.measure.contact  # Someone
v.modality # Component("self-report")

CSV 文件格式

CSV 文件应该用逗号分隔(这并不奇怪)并且有 DOS 行结尾 (CRLF)。他们一开始不应该有愚蠢的 UTF-8 签名。UTF-8 字符很好。缺失数据由空单元格指示。引用应该像 Excel 那样。

基本上,您需要没有 UTF-8 签名的 Excel-for-Windows 样式的 CSV 文件。

字典

  • CSV 格式
  • 至少有两列:组件,短名称
  • 这些是索引
  • 索引中不应有任何重复
  • settings.json 文件应该包含一个“组件”的东西,说明应该存在于组件列中的内容
  • 带有空白组件的东西被忽略(TODO:也许?)

排除文件

  • CSV 格式
  • 住在排除/
  • 每个 ppt 一行,每个值一列
  • 有索引列,和数据文件一样
  • 空白表示“使用此值”,非空白表示“排除此值”
  • 细胞中的东西可能是代码;这些代码可以在 settings.json 中定义
  • 如果出于多个原因排除数据,请用“,”分隔代码
  • 并非主文件中的所有行/列都需要包含在排除文件中。缺少的行/列被视为空白值。

数据检查

以下是一些(全部?)验证您是否拥有语义上合理的数据的事情:

  • 字典中没有的可变部分
  • 缺少参与者 ID 列
  • 重复的 paticipant_id 列
  • 参与者 ID 列中的空白
  • 重复列
  • 列名与格式不匹配

开始开发

创建一个虚拟环境:

virtualenv ~/env/masterfile
source ~/env/masterfile/bin/activate

安装需求和此模块以进行开发:

pip install -r requirements_dev.txt
pip install -e .

运行测试:

pytest

在所有受支持的 Python 版本上运行测试:

tox

要在特定的 python 版本中运行:

tox -e py37

学分

由 Nate Vack在 Dan Fitch 的帮助下编写 njvack@wisc.edu dfitch@wisc.edu

masterfile 封装了一些很棒的工具:schemaattrs

架构版权所有 (c) 2012 Vladimir Keleshev, vladimir@keleshev.com

attrs 是版权所有 (c) 2015 Hynek Schlawack

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

masterfile-0.6.0.tar.gz (26.5 kB 查看哈希

已上传 source