Import text files with extensions other than .txt

31 Ansichten (letzte 30 Tage)
Gollapalli Prince
Gollapalli Prince am 27 Feb. 2021
Kommentiert: Star Strider am 28 Feb. 2021
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

Akzeptierte Antwort

Star Strider
Star Strider am 27 Feb. 2021
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 Kommentare
Gollapalli Prince
Gollapalli Prince am 28 Feb. 2021
Thank you so much. I could import the data successfuly.
Star Strider
Star Strider am 28 Feb. 2021
As always, my pleasure!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by