Read numeric data as string data from csv (table.txt) file?

43 ビュー (過去 30 日間)
ARON ABHISHEK KUJUR
ARON ABHISHEK KUJUR 2018 年 7 月 5 日
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 件のコメント
ARON ABHISHEK KUJUR
ARON ABHISHEK KUJUR 2018 年 7 月 5 日
Here it is.
ARON ABHISHEK KUJUR
ARON ABHISHEK KUJUR 2018 年 7 月 5 日
Sorry. I forgot to attach preview of the variable after csv is loaded.

サインインしてコメントする。

採用された回答

Paolo
Paolo 2018 年 7 月 5 日
You may use the %s specifier to read your data as strings.
data = readtable('Table.txt','Format','%s%s');
  1 件のコメント
ARON ABHISHEK KUJUR
ARON ABHISHEK KUJUR 2018 年 7 月 5 日
Thanks for the answer. It works great.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by