Why does Readtable return NaN for values greater than 1000?
이전 댓글 표시
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
Daniel
2023년 11월 27일
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
2023년 11월 27일
Stephen23
2023년 11월 27일
"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
2023년 11월 27일
채택된 답변
추가 답변 (1개)
Walter Roberson
2023년 11월 27일
GDP = readtable(fileName2, "ThousandsSeparator",",");
카테고리
도움말 센터 및 File Exchange에서 Simulink에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!