Import text files with extensions other than .txt

32 visualizaciones (últimos 30 días)
Gollapalli Prince
Gollapalli Prince el 27 de Feb. de 2021
Comentada: Star Strider el 28 de Feb. de 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

Respuesta aceptada

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

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by