MATLAB: How to process a csv file where numbers and text are at the same column

csvprocesstext and numbers at the same column

Hello, everyone. I have the attached CSV file and there are some things that I have to do:
  1. create a table,
  2. read every text or number that they are, after the colon (:),
  3. read all the rows from 1-37 and
  4. transfer the variables names at the first row and the text and numbers to the second row meaning a table 2X37.
I kindly asking for help because I have totally 7400 files to process!!! Thank you in advance.

Best Answer

That's not a CSV file. You might have to write a custom reader for it. Here's a start:
fullFileName = fullfile(pwd, 'test2_seq.csv')
% Open the file.
fileID = fopen(fullFileName, 'rt');
% Read the first line of the file.
textLine = fgetl(fileID);
while ischar(textLine)
% Read the remaining lines of the file.
fprintf('%s\n', textLine);
if contains(textLine, '#DATE', 'IgnoreCase', true)
colonLocation = strfind(textLine, ':');
semicolonLocation = strfind(textLine, ';');
DATE = strtrim(textLine(colonLocation + 2 : semicolonLocation(1)));
elseif contains(textLine, '#TIME', 'IgnoreCase', true)
elseif contains(textLine, '#OWNER', 'IgnoreCase', true)
elseif contains(textLine, '#NPOINTS', 'IgnoreCase', true)
elseif contains(textLine, '#NCOLUMNS', 'IgnoreCase', true)
elseif contains(textLine, '#XUNITS', 'IgnoreCase', true)
elseif contains(textLine, '#YUNITS', 'IgnoreCase', true)
elseif contains(textLine, '#DATATYPE', 'IgnoreCase', true)
elseif contains(textLine, '#XPERCHAN', 'IgnoreCase', true)
elseif contains(textLine, '#OFFSET', 'IgnoreCase', true)
elseif contains(textLine, '#OFFSET', 'IgnoreCase', true)
elseif contains(textLine, '#LIVETIME', 'IgnoreCase', true)
elseif contains(textLine, '#SIGNALTYPE', 'IgnoreCase', true)
% etc.
end
% Read the next line.
textLine = fgetl(fileID);
end
% All done reading all lines, so close the file.
fclose(fileID);
Related Question