简体   繁体   English

Windows下在Octave 3.2.4中使用整数加载csv文件

[英]Load csv file with integers in Octave 3.2.4 under Windows

I am trying to import in Octave a file (ie data.txt) containing 2 columns of integers, such as: 我正在尝试在Octave中导入包含2列整数的文件(即data.txt),例如:

101448,1077
96906,924
105704,1017

I use the following command: 我使用以下命令:

data = load('data.txt')

However, the "data" matrix that results has a 1 x 1 dimension, with all the content of the data.txt file saved in just one cell. 但是,结果“数据”矩阵的尺寸为1 x 1,data.txt文件的所有内容都保存在一个单元格中。 If I adjust the numbers to look like floats: 如果我将数字调整为浮点数:

101448.0,1077.0
96906.0,924.0
105704.0,1017.0

the loading works as expected, and I obtain a matrix with 3 rows and 2 columns. 加载按预期方式工作,我获得了一个3行2列的矩阵。

I looked at the various options that can be set for the load command but none of them seem to help. 我看了可以为load命令设置的各种选项,但是似乎没有一个有用。 The data file has no headers, just plain integers, comma separated. 数据文件没有标头,只有纯整数,以逗号分隔。

Any suggestions on how to load this type of data? 关于如何加载此类数据有何建议? How can I force Octave to cast the data as numeric? 如何强制Octave将数据转换为数字?

The load function is not to read csv files. load功能是不读取csv文件。 It is meant to load files saved from Octave itself which define variables. 它旨在加载从Octave本身保存的定义变量的文件。

To read a csv file use csvread ("data.txt") . 要读取csv文件,请使用csvread ("data.txt") Also, 3.2.4 is a very old version no longer supported, you should upgrade. 另外,3.2.4是一个不再支持的非常旧的版本,您应该升级。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM