我有一个带有setup.py脚本的 Python 应用程序,可以通过 Pip 或 setuptools 安装。但是,我发现这两种方法之间存在一些烦人的差异,我想知道分发数据文件的正确方法。
import glob
import setuptools
long_description = ''
setuptools.setup(
name='creator-build',
version='0.0.3-dev',
description='Meta Build System for Ninja',
long_description=long_description,
author='Niklas Rosenstein',
author_email='rosensteinniklas@gmail.com',
url='https://github.com/creator-build/creator',
py_modules=['creator'],
packages=setuptools.find_packages('.'),
package_dir={'': '.'},
data_files=[
('creator', glob.glob('creator/builtins/*.crunit')),
],
scripts=['scripts/creator'],
classifiers=[
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python",
"Intended Audience :: Developers",
"Topic :: Utilities",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
],
license="MIT",
)
Run Code Online (Sandbox Code Playgroud)
data_files …我正在尝试从文件中读取一些数据,并且结束文件记录检测对于停止读取非常重要.但是,根据用于读取数据的数组的数组维度,我无法正确检测到endfile记录,并且我的Fortran程序停止.
该计划如下:
!integer, dimension(3) :: x ! line 1.1
!integer, dimension(3,10) :: x ! line 1.2
integer, dimension(10,3) :: ! line 1.3
integer :: status,i=1
character(len=100) :: error
open( 30, file='data.dat', status='old' )
do
print *,i
!read( 30, *, iostat=status, iomsg=error ) x ! line 2.1
!read( 30, *, iostat=status, iomsg=error ) x(:,i) ! line 2.2
read( 30, *, iostat=status, iomsg=error ) x(i,:) ! line 2.3
if ( status < 0 ) then print *,'EOF'
print *,'total of ',i-1,' lines …Run Code Online (Sandbox Code Playgroud) 在我的package_name子目录(位于“ setup.py”下的一个子目录)中,有一个“ logging.conf”文件。
如何在设置中包括它?
from distutils.sysconfig import get_python_lib
data_files=[(path.join(get_python_lib(), package_name),
path.join(path.dirname(__file__), package_name, 'logging.conf'))
Run Code Online (Sandbox Code Playgroud)
最好应该是简单的东西,例如:
data_files = [(package_name, path.join('.', package_name, 'logging.conf'))]
Run Code Online (Sandbox Code Playgroud)
错误:无法复制'c':不存在或不是常规文件
我正在尝试从 NCBI 或 PubMed 获取与数百个唯一 DOI 或 PMID 相关或附加的数据文件名,使用 R 语言。例如。我有 PMID:19122651 并且,我想获得连接到它的三个 GSE 的名称,它们是:GSE12781、GSE12782 和 GSE12783。我搜索了各种来源和软件包,但无济于事。
感谢您的帮助。
我正在用这种布局做一个项目:
project/
bin/
my_bin.py
CHANGES.txt
docs/
LICENSE.txt
README.txt
MANIFEST.in
setup.py
project/
__init__.py
some_thing.py
default_data.json
other_datas/
default/
other_default_datas.json
Run Code Online (Sandbox Code Playgroud)
问题是,当我使用pip安装它时,它将"default_data.json"和"other_datas"文件夹放在与应用程序其余部分不在同一位置.
我怎么做让他们在同一个地方?
他们最终在"/home/user/.virtualenvs/proj-env/project"
而不是"/home/user/.virtualenvs/proj-env/lib/python2.6/site-packages/project"
在setup.py中,我这样做:
inside_dir = 'project'
data_folder= os.path.join(inside_dir,'other_datas')
data_files = [(inside_dir, [os.path.join(inside_dir,'default_data.json')])]
for dirpath, dirnames, filenames in os.walk(data_folder):
data_files.append([dirpath, [os.path.join(dirpath, f) for f in filenames]])
Run Code Online (Sandbox Code Playgroud) 将运行时必需数据文件与Perl模块捆绑在一起的"正确"方法是什么,以便模块在使用之前可以读取其内容?
一个简单的例子是这个Dictionary模块,它需要在启动时读取(字,定义)对的列表.
package Reference::Dictionary;
# TODO: This is the Dictionary, which needs to be populated from
# data-file BEFORE calling Lookup!
our %Dictionary;
sub new {
my $class = shift;
return bless {}, $class;
}
sub Lookup {
my ($self,$word) = @_;
return $Dictionary{$word};
}
1;
Run Code Online (Sandbox Code Playgroud)
和一个驱动程序,Main.pl:
use Reference::Dictionary;
my $dictionary = new Reference::Dictionary;
print $dictionary->Lookup("aardvark");
Run Code Online (Sandbox Code Playgroud)
现在,我的目录结构如下所示:
root/
Main.pl
Reference/
Dictionary.pm
Dictionary.txt
Run Code Online (Sandbox Code Playgroud)
我似乎无法让Dictionary.pm在启动时加载Dictionary.txt.我已经尝试了一些方法来实现这一点,例如......
使用BEGIN块:
BEGIN {
open(FP, '<', 'Dictionary.txt') or die "Can't open: $!\n";
while (<FP>) {
chomp;
my ($word, …Run Code Online (Sandbox Code Playgroud)我正在尝试合并R中的数据,如我在其他帖子的答案中所建议的那样.但是,我有一个错误.
首先让我解释一下我的尝试.我有100个文件(每个都有x_i和y_i),我想以这种方式合并它们:
从:
x1; y1 ; x2 ; y2
1 ; 100 ; 1 ; 150
4 ; 90 ; 2 ; 85
7 ; 85 ; 10 ; 60
10; 80 ;
Run Code Online (Sandbox Code Playgroud)
至
x1; y1 ; x2 ; y2
1 ; 100 ; 1 ; 150
2 ; 100 ; 2 ; 85
4 ; 90 ; 4 ; 85
7 ; 85 ; 7 ; 85
10; 80 ;10 ; 60
Run Code Online (Sandbox Code Playgroud)
简单的脚本在玩具示例中运行良好:
xx <- …Run Code Online (Sandbox Code Playgroud) 我有一百个带三个字段的文件.每个看起来像这样(有更多行):
#time data1 data2
20 1.9864547484940e+01 -3.96363547484940e+01
40 2.164547484949e+01 -3.2363547477060e+01
60 1.9800047484940e+02 -4.06363547484940e+02
…
Run Code Online (Sandbox Code Playgroud)
它们很重,有些需要1.5G.我想通过以较低的双精度保存最后两列并删除该项来减小它们的大小e+0?.例如,我想将上面的四行转换为:
#time data1 data2
20 19.865 -39.636
40 21.645 -32.364
60 198.00 -406.36
…
Run Code Online (Sandbox Code Playgroud)
我用Google搜索并遇到了CONVFMT选项awk.但我不知道如何使用它,因为我真的不是awk的专业人士.这是在我的情况下使用的正确工具吗?如果是这样,我应该如何使用它?
我还想过编写一个C++脚本,但直接命令行会很棒.
在 Parquet 文件格式中使用嵌套数据类型是否有任何性能优势?
AFAIK Parquet 文件通常是专门为查询服务创建的,例如 Athena,因此创建这些文件的过程也可以简单地展平值 - 从而允许更容易的查询、更简单的架构,并保留每列的列统计信息。
使用嵌套数据类型有什么好处,例如struct?
我需要读取一个数据文件,其中的数字以如下格式写入:
1.0d-05
Run Code Online (Sandbox Code Playgroud)
C++ 似乎无法识别这种类型的科学记数法!关于如何读取/转换这些类型的数字的任何想法?
我需要数字(即double/ float)而不是字符串。也许已经有一个类/头来管理这种格式,但我找不到它。
data-files ×10
distutils ×2
fortran ×2
pip ×2
python ×2
r ×2
setuptools ×2
apache-spark ×1
awk ×1
c++ ×1
doi ×1
double ×1
eof ×1
gfortran ×1
installation ×1
linux ×1
merge ×1
na ×1
ncbi ×1
nested ×1
package ×1
parquet ×1
perl ×1
perl-module ×1
precision ×1
pubmed ×1
python-2.7 ×1
python-3.x ×1
zoo ×1