Skip to content

Instantly share code, notes, and snippets.

@guestl
Last active February 23, 2017 16:22
Show Gist options
  • Save guestl/1ef9025076276ea886150b2382f32dc8 to your computer and use it in GitHub Desktop.
Save guestl/1ef9025076276ea886150b2382f32dc8 to your computer and use it in GitHub Desktop.
load file string by string to list (utf-8 compatible)
def load_custom_directories_list_from_file(cdl_filename):
if os.path.isfile(cdl_filename):
try:
with codecs.open(cdl_filename, 'r', 'utf-8') as f:
cdl_file_content = f.readlines()
# remove special chars like `\n` at the end of each line
cdl_file_content = [x.strip() for x in cdl_file_content]
return cdl_file_content
except Exception as e:
logging.error(e)
raise e
return []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment