Effacer les filtres
Effacer les filtres

Import text files with extensions other than .txt

27 vues (au cours des 30 derniers jours)
Gollapalli Prince
Gollapalli Prince le 27 Fév 2021
Commenté : Star Strider le 28 Fév 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

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by