Why does Readtable return NaN for values greater than 1000?
Mostrar comentarios más antiguos
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 comentarios
Daniel
el 27 de Nov. de 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
el 27 de Nov. de 2023
Stephen23
el 27 de Nov. de 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
el 27 de Nov. de 2023
Respuesta aceptada
Más respuestas (1)
Walter Roberson
el 27 de Nov. de 2023
GDP = readtable(fileName2, "ThousandsSeparator",",");
Categorías
Más información sobre Simulink en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!