fopen cannot read directory names in scientific format

1 view (last 30 days)
Hi everyone, I have some data that is stored as .csv file in different directories. After looking through this forum, I have managed to find a way of extracting the relevant .csv file from the different directories, using the code provided in this post https://uk.mathworks.com/matlabcentral/answers/278950-i-m-trying-to-write-a-code-that-import-several-data-from-multiple-folder.
The code works fine until it encounters a directory name in scientific notation and it stops with the error:
Error using textscan
Invalid file identifier. Use fopen to generate a valid file identifier.
Error in multipleDirectories_subfolders_test (line 27)
MyData{end+1} = textscan(fileID, formatSpec, 'Delimiter', ',', 'HeaderLines',startRow-1); % format depends on files % this line might need changing
The code is attached. I've also tried using csvread but I still run into problems with this. After setting a few breakpoints in the code I've identified the problem to be the format of some directories being in scientific notation as shown in the following screenshot:
The code reads perfectly fine the .csv files in the 0, 0.0001, 0.00102, 0.000104, 0.000106 directories but the file identifier becomes invalid for the remaining directories.
Does anyone know how to solve this? It looks like fopen can only deal with integer type directories so the error is not due to textscan or csvread.
I'm really at a loss as to how to import the data otherwise.
p.s. The directories are by default saved in that format from a separate software and there's hundreds of them so changing the name manually is not really an option.
  19 Comments
Jacqueline Mifsud
Jacqueline Mifsud on 5 Jun 2020
Edited: Jacqueline Mifsud on 5 Jun 2020
I've tried this with NaN and although no values are plotted in the contourf plot for those matrix entries, I still cannot see both plots.
I think the problem might be something else, e.g. axis alignment. I'd like each contourf to have a separate colorbars and apparently each set of axes only supports one colorbar. So I've created two sets of axes since I want two color bars, and linked them with linkaxes - but it does not seem to be doing the trick.
Unfortunately I can't think of another workaround for this.

Sign in to comment.

Answers (0)

Categories

Find more on Data Import and Export 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!