def sanitize_filename(filename):
 filename = filename.replace(' ', '_')
 filename = filename.encode('utf-8')
 filename = (filename[0:25] + '.csv')
 return filename

def sanitize_filename ( filename ) : filename = filename . replace ( ' ' , '_' ) filename = filename . encode ( 'utf-8' ) filename = ( filename [ 0 : 25 ] + '.csv' ) return filename
return filename with illegal chars converted to legal ones and with the par2 extension always in lowercase .