Import text files with extensions other than .txt

조회 수: 30 (최근 30일)
Gollapalli Prince
Gollapalli Prince 2021년 2월 27일
댓글: Star Strider 2021년 2월 28일
I have a text file shown below. The file has .vasp extension.
When I changed the extension to .txt, the file is opening by entering readtable('filename.txt'), could you please help me open this file without changing extension to .txt ?
Ti4 N4
1.0
4.2535338402 0.0000000000 0.0000000000
0.0000000000 4.2535338402 0.0000000000
0.0000000000 0.0000000000 4.2535338402
N Ti
4 4
Direct
0.000000000 0.000000000 0.500000000
0.500000000 0.000000000 0.000000000
0.000000000 0.500000000 0.000000000
0.500000000 0.500000000 0.500000000
0.000000000 0.000000000 0.000000000
0.000000000 0.500000000 0.500000000
0.500000000 0.000000000 0.500000000
0.500000000 0.500000000 0.000000000

채택된 답변

Star Strider
Star Strider 2021년 2월 27일
Use detectImportOptions to tell readtable to read the file as a text file.
One recent example from an earlier Answer:
opts = detectImportOptions('breast-cancer-wisconsin.data', 'FileType','text');
BCTable = readtable('breast-cancer-wisconsin.data', opts);
A similar approach should also work for your files.
See Text and Spreadsheet Files in the readtable documentation for more information.
  댓글 수: 2
Gollapalli Prince
Gollapalli Prince 2021년 2월 28일
Thank you so much. I could import the data successfuly.
Star Strider
Star Strider 2021년 2월 28일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Whos에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by