Error with 'geosoftread' while reading file
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
MathWorks Support Team
el 10 de Nov. de 2020
Respondida: MathWorks Support Team
el 26 de Feb. de 2021
'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?
Respuesta aceptada
MathWorks Support Team
el 10 de Nov. de 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, :)
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Import and Management en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!