Reading text/number mixed CSV files as tables in Octave

狂风中的少年 提交于 2019-12-11 09:08:51

问题


is there an easy way in octave to load data from a csv in a data structure similar to dataframes in R? I tries csvread dlmread but octave keeps reading test a imaginary numbers, plus I'd like to have column's headers as references. I saw that there are some examples online which see way too twisted, how is it possible that there is not a function or something similar to dataframe of R? I say a package called dataframe but I can't seem to figure out how it works. Any tip or suggestion?

csvread('x') %returns 1 column imaginary numbers
dlmread('x') %returns N columns imaginary numbers

Any working alternative?


回答1:


Why are you unable to make the dataframe package work? You need to be more specific. Here's a simple example:

$ cat cars.csv 
Year,Make,Model
1997,Ford,E350
2000,Mercury,Cougar

$ octave
octave-cli-3.8.2:1> pkg load dataframe
octave-cli-3.8.2:2> cars = dataframe ("cars.csv")
cars = dataframe with 2 rows and 3 columns
Src: cars.csv                             
_1   Year    Make  Model                  
Nr double    char   char                  
 1   1997    Ford   E350                  
 2   2000 Mercury Cougar   


来源:https://stackoverflow.com/questions/28407344/reading-text-number-mixed-csv-files-as-tables-in-octave

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!