Using Textscan and Concatenation of multiple .txt files
1 view (last 30 days)
Show older comments
Hi,
I have files named T0.txt, T3.txt, T6.txt, ..., T600.txt, each is single column vector with 270 real numbers. I want to read these in one go, and concatenate into one single column array.
I can do this one at a time but it takes a very long time!
Does anyone know a way to use TEXTSCAN to open multiple .txt files and concatenate in one pass?
Any help would be appreciated!
robin
0 Comments
Answers (2)
Fangjun Jiang
on 20 Jun 2011
With 200 files (or 600 file) and each file contains 270x1 data, I wouldn't think it would take long if you write a program to read it one at a time and then concatenate them.
With that said, if you really want to do what you want, one possible way to do it is to combine all the text files together first.
This old DOS command can combine multiple files together.
copy t0.txt+t3.txt+T6.txt MyBigFatTextFile.txt
0 Comments
Walter Roberson
on 20 Jun 2011
textscan() does not open files at all: it operates on already-open file identifiers.
I cannot think at the moment of any MATLAB data-import function that handles sequences of files automatically. If there is one, it must be fairly special purpose, such as DICOM or financial series.
0 Comments
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!