Error with 'geosoftread' while reading file

5 Ansichten (letzte 30 Tage)
MathWorks Support Team
MathWorks Support Team am 10 Nov. 2020
'GETGEODATA' only returns NaNs for certain datasets (e.g. in reproduction steps). When it does so it also shows the following warning:
gplid = 'GPL21572';
url = sprintf('https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?form=text&acc=%s&view=full',gplid);
file = [tempdir '/' gplid '.txt'];
urlwrite(url, file);
gpldata = geosoftread( file );
Warning: Unable to read some lines of the file. Missing entries will be replaced with NaNs.
I also tried downloading the file and use 'getgeodata' but no luck.
Please, can I know if there is a workaround?

Akzeptierte Antwort

MathWorks Support Team
MathWorks Support Team am 10 Nov. 2020
The SOFT file is using three dashes "---" as a string to indicate missing data, and 'geosoftread' interprets this string, as a numeric value, but is unable to parse it as such. Additionally, 'geosoftread' returns NaN values for the entire row if any of the columns cannot be parsed, even if the remaining columns are valid. As almost all of the rows of data in this file have this issue, the entire data section appears a NaNs/empty characters.Below is a workaround to fix this issue where 'erase' is use to remove '---' while reading the data file. Note that the entries with '---' will now show up as empty char vectors ('').
 
gplid = 'GPL21572';
url = sprintf('https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?form=text&acc=%s&view=full',gplid);
file = [tempdir '/' gplid '.txt'];
urlwrite(url, file);
% Read file, strip out '---'
gplText = fileread(file);
gplText = erase(gplText, '---');
gplStripped = [tempdir '/' gplid '_stripped.txt'];
gplFID = fopen(gplStripped, 'w');
fprintf(gplFID, '%s', gplText);
fclose(gplFID);
% Entries with '---' will now show up as empty char vectors ('')
gpldata = geosoftread(gplStripped);
gpldata.Data(1:10, :)

Weitere Antworten (0)

Tags

Noch keine Tags eingegeben.

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by