Why does Readtable return NaN for values greater than 1000?
Afficher commentaires plus anciens
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 commentaires
Daniel
le 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
le 27 Nov 2023
Stephen23
le 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
le 27 Nov 2023
Réponse acceptée
Plus de réponses (1)
Walter Roberson
le 27 Nov 2023
GDP = readtable(fileName2, "ThousandsSeparator",",");
Catégories
En savoir plus sur Cell Arrays dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!