Error using textscan Unknown option '%f'
2 views (last 30 days)
Show older comments
Govind Sankar Madhavan Pillai Ramachandran Nair
on 14 Jan 2019
filename = 'Temp1.csv'
fileid = fopen(filename);
C = textscan(fileid,'%s',32,'%f',32,'delimiter',';');
Error using textscan
Unknown option '%f'
Why is this giving me such an error? %f is one of the formatspec in textscan. Then why is it giving me such an error.
0 Comments
Answers (1)
Star Strider
on 14 Jan 2019
I have no idea what you want to do.
Perhaps this:
C = textscan(fileid, '%s %f ', 'delimiter',';');
I added a space for each ‘32’ (the ASCII numerical code for a space), since I assume you intend that.
3 Comments
Stephen23
on 14 Jan 2019
Edited: Stephen23
on 14 Jan 2019
@Govind Sankar Madhavan Pillai Ramachandran Nair: neither the formatspec nor the N repeat. They each occur only once (N is optional), e.g.:
textscan(fileid, '%f%f%f', 4)
The format spec is usually written to match one whole line of the data file, while N is usually used to control how many lines of data are imported.
I suggest that you look at some of the documentation examples of how to use textscan, in particular taking a good look at examples of the format spec. You will find many examples just under the title Examples. Read them carefully.
Star Strider
on 14 Jan 2019
@Stephen — Thank you. I was ‘away’ for the last few minutes, responding to another Question.
See Also
Categories
Find more on Large Files and Big Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!