Not enough Input Arguments

11 vues (au cours des 30 derniers jours)
Sarthak Anand
Sarthak Anand le 10 Déc 2022
Commenté : Sarthak Anand le 10 Déc 2022
I was executing the code but there is an error showing:
Not enough input arguments.
Error in importStormData (line 44)
data = readtable(filename, opts)
The syntax is correct and the intialization of the opts variable has been done as follows:
opts = delimitedTextImportOptions("NumVariables", 23);
opts.DataLines = dataLines;
opts.Delimiter = ",";
opts.VariableNames = ["Var1", "Var2", "State", "Var4", "Month", "Event_Type", "Begin_Date_Time", "Timezone", "End_Date_Time", "Injuries_Direct", "Injuries_Indirect", "Deaths_Direct", "Deaths_Indirect", "Var14", "Property_Cost", "Var16", "Crop_Cost", "Begin_Lat", "Begin_Lon", "End_Lat", "End_Lon", "Episode_Narrative", "Event_Narrative"];
opts.SelectedVariableNames = ["Month", "Event_Type", "Begin_Date_Time", "Timezone", "Injuries_Direct", "Injuries_Indirect", "Deaths_Direct", "Deaths_Indirect", "Property_Cost", "Crop_Cost", "Begin_Lat", "Begin_Lon", "End_Lat", "End_Lon", "Episode_Narrative", "Event_Narrative"];
opts.VariableTypes = ["string", "string", "categorical", "string", "categorical", "categorical", "datetime", "categorical", "datetime", "double", "double", "double", "double", "string", "double", "string", "double", "double", "double", "double", "double", "categorical", "string"];
opts = setvaropts(opts, 7, "InputFormat", "yyyy-MM-dd HH:mm:ss");
opts = setvaropts(opts, 9, "InputFormat", "yyyy-MM-dd HH:mm:ss");
opts = setvaropts(opts, [1, 2, 4, 14, 16, 23], "WhitespaceRule", "preserve");
opts = setvaropts(opts, [1, 2, 3, 4, 5, 6, 8, 14, 16, 22, 23], "EmptyFieldRule", "auto");
opts.ExtraColumnsRule = "ignore";
opts.EmptyLineRule = "read";
  1 commentaire
Image Analyst
Image Analyst le 10 Déc 2022
Did you assign filename? What happens if you just omit the opts from the call to readtable?
If you have any more questions, then attach your data file with the paperclip icon after you read this:

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 10 Déc 2022
importStormData is a function that expects at least one parameter, which it refers to as filename . However when you ran the code, you did not provide a file name in the corresponding parameter slot.
The error is not saying that you did not provide enough input arguments to readtable, the error is saying that you did not provide enough input arguments to importStormData
  1 commentaire
Sarthak Anand
Sarthak Anand le 10 Déc 2022
Yes. I understand it now. Comitted an elementary rookie mistake and was fretting over it for a long time. Thanks for your support.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Type Conversion dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by