Why does Readtable return NaN for values greater than 1000?
Ältere Kommentare anzeigen
I was working with a dataset that contains the annual GDP of all countries in billion USD. However, when importing the dataset with readtable, the corresponding table omits all data points that are greater than 1000.
fileName2 = 'GDP by Country 1999-2022.csv';
GDP = readtable(fileName2);
The following is the original CSV data (see Canada)

Whereas the table GDP that readtable produces is as below

Is there a reason for this happening?
4 Kommentare
Daniel
am 27 Nov. 2023
What is the comma character , being used in more-than-a-thousand numbers to separate the thousands from hundreds? They should not be regular commas since your original file is a CSV. Maybe the character is the problem causing Matlab to not recognize these numbers.
Kevin
am 27 Nov. 2023
Stephen23
am 27 Nov. 2023
"the authors used double-quotes for any number greater than 1000"
Ugh.
"Any suggestions on how to convert these strings to double while importing?"
Upload a sample data file by clicking the paperclip button.
Kevin
am 27 Nov. 2023
Akzeptierte Antwort
Weitere Antworten (1)
Walter Roberson
am 27 Nov. 2023
GDP = readtable(fileName2, "ThousandsSeparator",",");
Kategorien
Mehr zu Simulink finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!