Ho to separate multiple files into individual columns?
Show older comments
I have a folder containing 160 .txt files and need to pull them into a matlab matrix and then into vectors. Each file contains a review string which has already been converted into single words per row(e.g. Is this a sentence? becomes
'Is' 'this' 'a' 'sentence' 'QUESTION_MARK')
What I am trying to do is pull the documents into Matlab and then each word for the file will shown in rows and then each document carried over to the next column. The code I have does pull in the documents and every line of text for all 160 files from the selected folder but it lists al the data down one column where I need to have one file to a column. I know there is a way to do this but I cannot seem to find a solution that works with my code.
if true
fpath = ('C:\Users\Willem\Documents\MATLAB\fold1');
files = dir(fullfile(fpath,'*.oneline'));
nfiles = length(files);
data = [];
for k = 1:nfiles
data = [data; importdata(fullfile(fpath,files(k).name))];
end
end
Any and all help will be very much appreciated.
Accepted Answer
More Answers (0)
Categories
Find more on Large Files and Big Data 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!