I have a multiple .txt files (31) each containing 4 columns with headers and 2000 rows.
What I am trying to do is, to import the first 1000 column for each file and combine them into a table by horizontal concatenation and do the same for the second 1000 column to obtain a second table than write them into 2 separate excel files.
I have read most of the related headers but it seems a bit challenging to manage the files with unpatterned names. I have attached a couple of the .txt files for an example.
I used the "generate function" from the import tool which works fine, but does the job for only a single .txt file. Is it possible to insert a loop into this auto generated function? Or is there a simpler way?
function mA = importfile1(filename, dataLines)
if nargin < 2
dataLines = [2, Inf];
opts = delimitedTextImportOptions("NumVariables", 4);
opts.DataLines = dataLines;
opts.Delimiter = "\t";
opts.VariableNames = ["PointsReference", "AmplitudeReference", "PointsSample", "AmplitudeSample"];
opts.VariableTypes = ["double", "double", "double", "double"];
opts.ExtraColumnsRule = "ignore";
opts.EmptyLineRule = "read";
mA = readtable(filename, opts);
Any help could be really appreciated since I am trying to figure this out for 3 days.
Thank you all in advance