Python

Textual information is the most important form of data in almost every application. In an online shopping website, we use text to provide production descriptions. Textual data, as well as files and numeric data, can all be saved as text files, reading which all requires us to process strings. We know that machine learning is trending, and one critical machine learning specialty is termed natural language processing (NLP). NLP is concerned with extracting information from texts. Because of this, text processing is an inevitable step in preparing the data in these applications. In short, there are numerous real-life cases where we need to process and format strings properly.

Here is an example of how to get a file list from an assigned directory recursively.

            
            import sys, shutil, os, re
    
            def list_file(root_dir):
    
              obj = []
    
              for root, dirs, files in os.walk(root_dir):
                for file in files:
                    if file.endswith('.py') or file.endswith('.cgi') :
                    full_obj = os.path.join(root,file)
                    obj.append(full_obj)
    
              return obj
    
            def main():
              sRootDir = "/home/username"
              aFileList = list_file(sRootDir)
    
            if __name__ == '__main__':
              main()