How to solve "Error using split First argument must be text"
74 views (last 30 days)
Having issues with my script. Everytime I run it, I get an error "Error using split. First argument must be text."
Stacked = readtable(root_folder 'Stacked.xlsx');
dates = Stacked.General_Prompt_SurveySubmittedDate_1;
c = split(dates, '/');
c(:, 3) = cellfun(@fliplr, c(:,3), 'UniformOutput', false);
datesNew = join(c, '/');
I'm not sure how to fix it. What I want to do is get the data to split and then flip all the years. Then I want to join it.
But I keep getting the error at the line "c=split..." so I'm not able to get it to run.
I have attached my dataset.
Walter Roberson on 25 Jul 2022
readtable is returning that column as datetime objects. You cannot split() datetime objects.
mask = dates < datetime(1000, 1,1);
dates(mask) = dates(mask) + calyears(2000);
No splitting or text processing necessary.