title: Getting the latest files from FTP folder (filename having spaces) in Python
body: <p>I have a requirement where I have to pull the latest files from an FTP folder, the problem is that the filename is having spaces and the filename is having a specific pattern.
  Below is the code I have implemented:</p>
  
  <pre><code>import sys
  from ftplib import FTP
  import os
  import socket
  import time
  import pandas as pd
  import numpy as np
  from glob import glob
  import datetime as dt
  from __future__ import with_statement
  
  ftp = FTP('')
  ftp.login('','')
  ftp.cwd('')
  ftp.retrlines('LIST')
  
  filematch='*Elig.xlsx'
  downloaded = []
  
  for filename in ftp.nlst(filematch):
    fhandle=open(filename, 'wb')
    print 'Getting ' + filename
    ftp.retrbinary('RETR '+ filename, fhandle.write)
    fhandle.close()
    downloaded.append(filename)
  
  ftp.quit()
  </code></pre>
  
  <p>I understand that I can append an empty list to ftp.dir() command, but since the filename is having spaces, I am unable to split it in the right way and pick the latest file of the type that I have mentined above.</p>
  
  <p>Any help would be great.</p>