NumPy中loadtxt()函数,usecol=None Wrong number of columns

本文探讨了使用NumPy的loadtxt函数读取CSV文件时遇到的错误,并尝试通过设置usecols参数来解决读取列数限制的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.问题

当使用loadtxt去读取csv文件时会出现Wrong number of columns的问题


2.分析

经本人用设置usecol的参数的方法进行实验,usecol = (0,1,.....20)这个方式进行实验发现,最多可以读取23列就会出现,list index out of range的问题,所以猜想应该是loadtxt限制了读取的数据的列数


3.本人新学NumPy,如分析有误,望大神指教


(mast3r-slam) root@autodl-container-89914fa1bb-a01dbef1:~/MASt3R-SLAM# bash ./scripts/eval_euroc.sh ~/autodl-fs/datasets/euroc/MH_05_difficult/ {'use_calib': True, 'single_thread': True, 'dataset': {'subsample': 2, 'img_downsample': 1, 'center_principle_point': True}, 'matching': {'max_iter': 10, 'lambda_init': 1e-08, 'convergence_thresh': 1e-06, 'dist_thresh': 0.1, 'radius': 3, 'dilation_max': 5}, 'tracking': {'min_match_frac': 0.05, 'max_iters': 50, 'C_conf': 0.0, 'Q_conf': 1.5, 'rel_error': 0.001, 'delta_norm': 0.001, 'huber': 1.345, 'match_frac_thresh': 0.333, 'sigma_ray': 0.003, 'sigma_dist': 10.0, 'sigma_pixel': 1.0, 'sigma_depth': 10.0, 'sigma_point': 0.05, 'pixel_border': -10, 'depth_eps': 1e-06, 'filtering_mode': 'weighted_pointmap', 'filtering_score': 'median'}, 'local_opt': {'pin': 1, 'window_size': 1000000.0, 'C_conf': 0.0, 'Q_conf': 1.5, 'min_match_frac': 0.1, 'pixel_border': -10, 'depth_eps': 1e-06, 'max_iters': 10, 'sigma_ray': 0.003, 'sigma_dist': 10.0, 'sigma_pixel': 1.0, 'sigma_depth': 10.0, 'sigma_point': 0.05, 'delta_norm': 1e-08, 'use_cuda': True}, 'retrieval': {'k': 3, 'min_thresh': 0.005}, 'reloc': {'min_match_frac': 0.3, 'strict': True}, 'inherit': 'config/base.yaml'} Traceback (most recent call last): File "/root/MASt3R-SLAM/main.py", line 170, in <module> dataset = load_dataset(args.dataset) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/MASt3R-SLAM/mast3r_slam/dataloader.py", line 325, in load_dataset return EurocDataset(dataset_path) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/MASt3R-SLAM/mast3r_slam/dataloader.py", line 100, in __init__ tstamp_rgb = np.loadtxt(rgb_list, delimiter=",", dtype=np.unicode_, skiprows=0) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/miniconda3/envs/mast3r-slam/lib/python3.11/site-packages/numpy/lib/npyio.py", line 1373, in loadtxt arr = _read(fname, dtype=dtype, comment=comment, delimiter=delimiter, ^^^^^^^^^^^^^^^^
最新发布
04-01
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值