Error with 'geosoftread' while reading file

5 ビュー (過去 30 日間)
MathWorks Support Team
MathWorks Support Team 2020 年 11 月 10 日
回答済み: MathWorks Support Team 2021 年 2 月 26 日
'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?

採用された回答

MathWorks Support Team
MathWorks Support Team 2020 年 11 月 10 日
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, :)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Import and Management についてさらに検索

タグ

タグが未入力です。

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by