Bird
0
0

What is wrong with this code snippet?

medium📝 Debug Q7 of 15
MATLAB - File I/O
What is wrong with this code snippet?
opts = detectImportOptions('file.csv');
opts.Delimiter = ';';
data = readtable('file.csv', opts);
ADelimiter should be set before calling detectImportOptions
BDelimiter property is read-only and cannot be changed
CDelimiter must be a comma for CSV files
DNo error, code is correct
Step-by-Step Solution
Solution:
  1. Step 1: Role of detectImportOptions

    detectImportOptions('file.csv') creates an import options object by analyzing the file.
  2. Step 2: Modifying Delimiter property

    The Delimiter property is modifiable after creation; setting opts.Delimiter = ';' is valid.
  3. Final Answer:

    No error, code is correct -> Option D
  4. Quick Check:

    Delimiter property is modifiable after detectImportOptions [OK]
Quick Trick: Delimiter can be set after detectImportOptions [OK]
Common Mistakes:
  • Thinking Delimiter is read-only
  • Believing delimiter must be comma
  • Confusing property modification rules

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More MATLAB Quizzes