Created
August 16, 2017 22:31
-
-
Save anjandev/c640ba87111244e1734fbd88b4629a66 to your computer and use it in GitHub Desktop.
Copy every Nth line algorithm (octave)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clear all | |
function newFinal = addAndConcat(oldFinal, newEnding) | |
% Copy every 30th line | |
N=30; | |
fid = newEnding; | |
% Delete top 3 lines | |
C = textread(fid, '%s', 'Delimiter', '\n', 'HeaderLines',3); | |
C = C(1:N:length(C)); | |
newFinal = [oldFinal; C]; | |
end | |
function newFinal = firstFileAddAndConcat(file) | |
% Copy every 30th line | |
N=30; | |
fid = file; | |
% Delete top 3 lines | |
newFinal = textread(fid, '%s', 'Delimiter', '\n', 'HeaderLines',3); | |
newFinal = newFinal(1:N:length(newFinal)); | |
end | |
newFinal = firstFileAddAndConcat('.csv'); | |
newFinal = addAndConcat(newFinal, '.csv'); | |
newFinal = addAndConcat(newFinal, '.csv'); | |
% etc. | |
fid = fopen('FINAL_ALL.txt','wt'); | |
formatSpec = '%s\n'; | |
[nrows,ncols] = size(newFinal); | |
for row = 1:nrows | |
fprintf(fid,formatSpec,newFinal{row,:}); | |
end | |
fclose(fid); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment