Converting numeric strings in cell to number for very large dataset
조회 수: 3(최근 30일)
I have read this post which does something similar: https://uk.mathworks.com/matlabcentral/answers/375506-coverting-numeric-strings-in-cell-to-numbers
However I wanted to know if there is a more efficient way to do this as my data-set is very large. My dataset contains both text and numbers I what to convert numbers only to number format.
This code takes about 124 seconds to run
I have tried preallocating Qnum but the run time is about the same:
Guillaume 2018년 1월 11일
The simplest way to read the example file, assuming you're on R2013b or later:
data = readtable('midas_marine-obs-lon-band-f_200901-200912.txt');
That's it! Numbers are read as numbers, text as text, dates as datetime. readtable figures it all out for you.
If you want to name the columns according to the other file, it's just as easy:
headers = readtable('MO_Column_Headers.txt');
data.Properties.VariableNames = headers.Properties.VariableNames
All done, only takes a few seconds to run.