readTable() interprets columns as numeric if first 250 entries are empty
이전 댓글 표시
I am using readTable() to import a tab-delimited .txt file with many rows (~10,000) and several columns of non-numeric data. Some of the columns have many empty entries, which I have stored as empty quotes ("").
For most columns, readTable is able to import the data just fine. However, I noticed that some columns are interpreted as numeric, and therefore the entire column is imported as NaNs. I discovered that this happens for columns whose first ~250 rows are all empty, even the rest of their rows are not empty.
I know that I can explicitly specify that my format type is all strings, but it seems to me that the readTable function should be able to automatically detect this, especially when I'm using quotes for all entries in the .txt file (even the empty entries). Also, I need to use this function for .txt files that have both numeric and text columns, and I really don't want to hard-code the expected format type of every column...
댓글 수: 1
Mehdi Ansarey
2024년 12월 16일
Thanks, I had the same issue, when a column has sparse string, and matlab read its content as NaN.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!