Greetings,
Having trouble with readtable with text files. The text files in question have a combination of text and number, thus the reason for using readtable. The script runs through the first two text files with no issues then crashes on the first line of the next text file.
while row <= height(workfile) %Height command identifies the number of rows in the table to stop the loop.
t=workfile(row, col); % t is a temp variable to store the date before processed by datenum
t=table2array(t); % convert to an array
t=datenum(t); % process to a datenum value
col=3; % set column to 3 to pull precip data
% now pull the precip data
p=workfile(row, col); p=table2array(p); Vdata=[t, p]; %temp variable to allow easier use of the fid process
fid=fopen (verfile , 'a'); fprintf(fid, '%6.0f, %7.4f \n ' , Vdata); fclose(fid);
The datenum line executes fine but it appears the issue comes up with the fprintf command as I get this error
Error using fprintfFunction is not defined for 'cell' inputs.Error in sitedata (line 95) fprintf(fid, '%6.0f, %7.4f \n ' , Vdata);
LIke I said, this was not an issue with the previous text files that were sucessfully run before so I am stumped. Below is a sample of the text files in question:
10/31/2018 0 011/1/2018 0 011/2/2018 0 011/3/2018 0 011/4/2018 T 0.000111/5/2018 0 011/6/2018 0 011/7/2018 0 011/8/2018 T 0.000111/9/2018 0.19 0.1911/10/2018 0 0
This is what the file before the one the crashed look like (top of the file).
Here is the one the script crashed on (same area of the file):
10/31/2018 0 011/1/2018 0.1 0.111/2/2018 0.45 0.4511/3/2018 0 011/4/2018 0.5 0.511/5/2018 0.14 0.1411/6/2018 0.11 0.1111/7/2018 0 011/8/2018 0 011/9/2018 0.12 0.1211/10/2018 0 0
Other than the data, they don't look any different. Any ideas??
Best Answer