Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matlab cannot read "numeric" field from csv

Tags:

csv

matlab

I am trying to read a csv file into Matlab using the following command

data=csvread('/econ/research/rd123/RAIS/Chuhang/data/final_samples/growth_regs_RandI_ALL.csv',1,0);

But matlab produced the following message:

{Error using dlmread (line 138) Mismatch between file and format string. Trouble reading 'Numeric' field from file (row number 1, field number 1) ==> "00000000000272",440,"65","13007",1995,6586,.1776316,-.1045213,.2821529,.0000105,.0002363,.0378644,.0078976\n

Error in csvread (line 47) m=dlmread(filename, ',', r, c);

Error in import_all_mfn (line 13) data=csvread('/econ/research/rd123/RAIS/Chuhang/data/final_samples/growth_regs_RandI_ALL.csv',1,0);

Does anyone know what the problem might be? Thanks in advance!

-Chuhang

like image 459
Chuhang Yin Avatar asked Sep 02 '25 10:09

Chuhang Yin


1 Answers

Use

 T = readtable(filename);
 firstcolumn = T{:,1};

This function reads all table but you must use indices as cells.

Also there is an explanation here. https://uk.mathworks.com/help/matlab/ref/readtable.html

like image 193
srkn sltrk Avatar answered Sep 04 '25 00:09

srkn sltrk