filename = 'C:\Users\User\Desktop\Masterprojektarbeit 2\Lösungsansatz2\Abaqus-Balken-Versuch1\Job-1.inp';
delimiter = ' ';


%% Read columns of data as strings:
% For more information, see the TEXTSCAN documentation.
formatSpec = '%s %s %s %s %s';
%formatSpec = '%*s%*s%*s%*s%s%[^\n\r]';

%% Open the text file.
fileID = fopen(filename,'r');

dataArray = textscan(fileID, formatSpec,'Delimiter', delimiter, 'MultipleDelimsAsOne', true, 'ReturnOnError', false);

%% Close the text file.
fclose(fileID);

raw = repmat({''},length(dataArray{1}),length(dataArray)-1);
for col=1:length(dataArray)-1
    raw(1:length(dataArray{col}),col) = dataArray{col};
end
numericData = NaN(size(dataArray{1},1),size(dataArray,2));

% Converts strings in the input cell array to numbers. Replaced non-numeric
% strings with NaN.
rawData = dataArray{1};
%%%%%%%%%%%%
%Lorenz 20.04.17
D=regexprep(raw, ',', '')
%a={'Hallo', 'Hallo', 'Hallo';'Hallo', 'Hallo', 'Hallo';'Hi', 'Hallo', 'Hallo'}
logicalpos = strcmp(D,'*Node')
[Zeile,Spalte]=find(logicalpos)

%D=rawData

for row=1:size(rawData, 1);
    % Create a regular expression to detect and remove non-numeric prefixes and
    % suffixes.
    regexstr = '(?<prefix>.*?)(?<numbers>([-]*(\d+[\,]*)+[\.]{0,1}\d*[eEdD]{0,1}[-+]*\d*[i]{0,1})|([-]*(\d+[\,]*)*[\.]{1,1}\d+[eEdD]{0,1}[-+]*\d*[i]{0,1}))(?<suffix>.*)';
    try
        result = regexp(rawData{row}, regexstr, 'names');
        numbers = result.numbers;
        
        % Detected commas in non-thousand locations.
        invalidThousandsSeparator = false;
        if any(numbers==',');
            thousandsRegExp = '^\d+?(\,\d{3})*\.{0,1}\d*$';
            if isempty(regexp(thousandsRegExp, ',', 'once'));
                numbers = NaN;
                invalidThousandsSeparator = true;
            end
        end
        % Convert numeric strings to numbers.
        if ~invalidThousandsSeparator;
            numbers = textscan(strrep(numbers, ',', ''), '%f');
            numericData(row, 1) = numbers{1};
            raw{row, 1} = numbers{1};
        end
    catch me
    end
end

%logicalposNaN = strcmp(numericData,'NaN')

%KK=size(1,5)
n=Zeile+1
BB=isnan(numericData(:,1))
for i = 1:row
   if  BB(n,1)== 0 
       cc=D(n,:);
       KK(i,1)=cc(1,1)
       KK(i,2)=cc(1,2)
       KK(i,3)=cc(1,3)
       KK(i,4)=cc(1,4)
   else
        break
        
   end
   n=n+1
end

GG=str2double(KK)
fid = fopen('C:\Users\User\Desktop\Masterprojektarbeit 2\Lösungsansatz2\Matlab4\Ausgabe\AutoScan.txt','w');
fprintf(fid,'%d\t %f\t %f\t %f\r\n',GG');
fclose(fid);