Skip to content

Instantly share code, notes, and snippets.

@Raggles
Created January 28, 2016 22:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Raggles/891991fe51a073e88e29 to your computer and use it in GitHub Desktop.
Save Raggles/891991fe51a073e88e29 to your computer and use it in GitHub Desktop.
%%concap recrod splitter
function splitter (strFilename)
intRecordNumber = 1;
fid = fopen(strFilename);
bEOF = false;
while (!bEOF)
strLine = fgetl(fid);
if (strLine == -1)
bEOF = true;
continue;
endif;
if (strncmp(strLine,"START_OF_TRACE",14))
strTime = fgetl(fid);
strReason = fgetl(fid);
strTime = strftime ("%Y.%m.%d %a %H.%M.%S", localtime(str2double(strTime)));
bEOR = false; %reset end of record flag
strOutFileName = strcat(strTime, "_", int2str(intRecordNumber), "_", strReason);
fidout = fopen(strOutFileName,"w");
intRecordNumber = intRecordNumber + 1;
while (!bEOR)
strLine = fgetl(fid);
if (strLine == -1)
bEOR = true;
continue;
endif;
if (strncmp(strLine, " END_OF_TRACE",10) || length(strLine) < 20)
bEOR = true;
else
fprintf(fidout,"%s \r\n",strLine);
endif;
endwhile;
fclose(fidout);
endif;
endwhile;
fclose(fid);
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment