{0*0 char} error while Importing .dat file

조회 수: 10 (최근 30일)
Muhammad Farooq Zia
Muhammad Farooq Zia 2021년 8월 23일
답변: Jeremy Hughes 2021년 8월 23일
Hi Matlab Community,
I hope you are all doing well. I am trying to import a .dat file in matlab using readtable function. I am facing two problems with this step:
  1. Once the table is loaded, it is showing some numerical values as characters. As shown below, by red annotation. These values e.g. {'8468'} and {'2570'} should show simply as 8468 and 2570.
  2. Second, (referring to blue notations), some empty cells from .dat file are read as NaN while others are assigned {0*0 char} variable type. I want all the empty cells as NaN, so I can use table2array function to convert this table to array form.
I am attaching the .csv file for the data as I cannot attach .dat file here. (Note: exact same problems happen even if I try using .csv file in readtable for importing data). Please help me out on this.
Thanks

채택된 답변

Jeremy Hughes
Jeremy Hughes 2021년 8월 23일
Instead of readtable and table2array, you could instead use readmatrix (as of R2019a) directly.
The reason some of the columns are being read as characters is that the file contains many mostly empty columns; readtable doesn't know what type they should be since it doesn't do type detection on the whole file.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by