Error with 'geosoftread' while reading file

조회 수: 4 (최근 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 CenterFile Exchange에서 Data 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