Read numeric data as string data from csv (table.txt) file?
조회 수: 22 (최근 30일)
이전 댓글 표시
Hi, matlab community.
I have a CSV file like:: 01,adam 02,eve 03,jenson
Now when I try to read this csv file (stored locally as table.txt) using readtable() it reads with imperfections. It stores all data correctly into 2-D array but "01" is stored as "1".
Is there any way to fix it? I want it exactly as it is in the file, i.e, as "01". Or, any way to convert numeric data to string data before it is stored in matlab variable.
댓글 수: 3
채택된 답변
Paolo
2018년 7월 5일
You may use the %s specifier to read your data as strings.
data = readtable('Table.txt','Format','%s%s');
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!