Why do I receive Error in matlab.io.​FTP/dir>ca​se12Parse ?

10 vues (au cours des 30 derniers jours)
Rose Mary
Rose Mary le 8 Fév 2023
I have the following script for downloading data using ftp.
rm_dir = 'rx_data/station_name/year/month/day_of_year';
rm_file = 'COCO0010.22o';
ftpobj = ftp(host,username,password);
cd (ftpobj,rm_dir);
mget(ftpobj,rm_file);
But I receive an error as follows.
Error using matlab.io.ftp.parseDirListingForWindows
Unable to parse dir output from the remote server.
Use 'ParseOutput' false to get the dir output as a string,or provide a custom parsing function using the 'DirParserFcn' Name-Value pair,
or set the ServerLocale property to the correct locale.
Error in matlab.io.FTP/dir>case12Parse (line 170)
listing = parseDirListingForWindows(listing, 1, namesOnly, ...
Error in matlab.io.FTP/dir (line 72)
varargout{1} = case12Parse(obj, options, listing, ...
Error in matlab.io.FTP/mget (line 39)
[dirStruct, folderOrFile] = dir(obj, str);
Error in ftp_download (line 11)
mget(ftpobj,rm_file)
How can I resolve this ?

Réponse acceptée

Raghav
Raghav le 10 Mar 2023
Modifié(e) : Raghav le 10 Mar 2023
Hi,
Based on your question, I understand that you want to know about the error matlab.io.FTP/dir>case12Parse.
The matlab.io.FTP/dir>case12Parse error in MATLAB typically occurs when there is an issue with parsing the directory listing returned by the FTP server. This error can occur if the directory listing returned by the server is not in the expected format or if there are connection issues between MATLAB and the FTP server.
The error message suggests a few possible solutions:
  • Use the 'ParseOutput' option with a value of false to get the raw directory listing as a string. You can then parse the listing yourself to extract the information you need. Here's an example of how to use this option:
dirListing = dir(ftpobj, rm_dir, 'ParseOutput', false);
  • Provide a custom parsing function using the 'DirParserFcn' option. This function should take the raw directory listing string as input and return a structure array with information about the files and folders. Here's an example of how to use this option:
dirListing = dir(ftpobj, rm_dir, 'DirParserFcn', @customDirParser);
In this example, you would need to define the 'customDirParser' function to parse the raw directory listing string and return the structure array.
  • Set the ServerLocale property to the correct locale for the FTP server. This tells MATLAB how to interpret the directory listing format. You can set the property like this:
ftpobj.ServerLocale = 'en_US.UTF-8';
Replace 'en_US.UTF-8' with the appropriate locale for your FTP server.
Once you have resolved the directory listing issue, you should be able to use the mget command to download the file.
For more information about “dir” in FTP, please check the following documentation:
Hope it helps!
Regards,
Raghav Bansal

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by