%% Import data from text file.
% Script for importing data from the following text file:
%
%    C:\Users\Barbara Karl\Documents\MATLAB\Auswertung-2018-ZVM\ausschnitt_test_einlesen.csv
%
% To extend the code to different selected data or a different text file,
% generate a function instead of a script.

% Auto-generated by MATLAB on 2018/11/26 07:40:10

%% Initialize variables.
filename = 'C:\Users\Barbara Karl\Documents\MATLAB\Auswertung-2018-ZVM\ausschnitt_test_einlesen.csv';
delimiter = ';';
startRow = 2;

%% Format for each line of text:
%   column1: text (%s)
%	column2: double (%f)
%   column3: text (%s)
%	column4: double (%f)
%   column5: text (%s)
%	column6: text (%s)
%   column7: text (%s)
%	column8: text (%s)
%   column9: double (%f)
%	column10: text (%s)
%   column11: text (%s)
%	column12: categorical (%C)
%   column13: categorical (%C)
%	column14: text (%s)
%   column15: text (%s)
%	column16: text (%s)
%   column17: text (%s)
%	column18: text (%s)
%   column19: text (%s)
%	column20: datetimes (%{dd.MM.yyyy HH:mm}D)
%   column21: datetimes (%{dd.MM.yyyy HH:mm}D)
%	column22: text (%s)
%   column23: text (%s)
% For more information, see the TEXTSCAN documentation.
formatSpec = '%s%f%s%f%s%s%s%s%f%s%s%C%C%s%s%s%s%s%s%{dd.MM.yyyy HH:mm}D%{dd.MM.yyyy HH:mm}D%s%s%[^\n\r]';

%% Open the text file.
fileID = fopen(filename,'r');

%% Read columns of data according to the format.
% This call is based on the structure of the file used to generate this
% code. If an error occurs for a different file, try regenerating the code
% from the Import Tool.
dataArray = textscan(fileID, formatSpec, 'Delimiter', delimiter, 'TextType', 'string', 'HeaderLines' ,startRow-1, 'ReturnOnError', false, 'EndOfLine', '\r\n');

%% Close the text file.
fclose(fileID);

%% Post processing for unimportable data.
% No unimportable data rules were applied during the import, so no post
% processing code is included. To generate code which works for
% unimportable data, select unimportable cells in a file and regenerate the
% script.

%% Create output variable
ausschnitttesteinlesen = table(dataArray{1:end-1}, 'VariableNames', {'Spalte1','Spalte2','Spalte3','Spalte4','Spalte5','Spalte6','Spalte7','Spalte8','Spalte9','Spalte10','Spalte11','Spalte12','Spalte13','Spalte14','Spalte15','Spalte16','Spalte17','Spalte18','Spalte19','Spalte20','Spalte21','Spalte22','Spalte23'});

% For code requiring serial dates (datenum) instead of datetime, uncomment
% the following line(s) below to return the imported dates as datenum(s).

% ausschnitttesteinlesen.Spalte20=datenum(ausschnitttesteinlesen.Spalte20);
% ausschnitttesteinlesen.Spalte21=datenum(ausschnitttesteinlesen.Spalte21);

%% Clear temporary variables
clearvars filename delimiter startRow formatSpec fileID dataArray ans;