How to read multiple text files from folder in Python? Read Courses Practice Improve Improve Improve Like Article Like Save Article Save Report issue Report Prerequisite: File Handlingos Python is a strong language which is extremely capable even when it comes to file handling. In this article, we will learn how to read multiple text files from a folder using python. Approach: Import modulesAdd path of the folderChange directoryGet the list of a file from a folderIterate through the file list and check whether the extension of the file is in .txt format or not.If text-file exist, read the file using File Handling Functions used: os.chdir() method in Python used to change the current working directory to specified path. It takes only a single argument as new directory path. Syntax: os.chdir(path) Parameters: path: A complete path of directory to be changed to new directory path. Returns: Doesn’t return any value os.listdir() method in python is used to get the list of all files and directories in the specified directory. If we don’t specify any directory, then list of files and directories in the current working directory will be returned. Syntax: os.listdir(path) Parameters: path (optional) : path of the directory Return Type: This method returns the list of all files and directories in the specified path. The return type of this method is list. Below is the Implementation: Program: Python3 # Import Module import os # Folder Path path = "Enter Folder Path" # Change the directory os.chdir(path) # Read text File def read_text_file(file_path): with open(file_path, 'r') as f: print(f.read()) # iterate through all file for file in os.listdir(): # Check whether file is in text format or not if file.endswith(".txt"): file_path = f"{path}\{file}" # call read text file function read_text_file(file_path) Output: https://media.geeksforgeeks.org/wp-content/uploads/20210125102530/FreeOnlineScreenRecorderProject4.mp4 Don't miss your chance to ride the wave of the data revolution! Every industry is scaling new heights by tapping into the power of data. Sharpen your skills and become a part of the hottest trend in the 21st century. Dive into the future of technology - explore the Complete Machine Learning and Data Science Program by GeeksforGeeks and stay ahead of the curve. Last Updated : 02 Feb, 2021 Like Article Save Article Previous Read a CSV into list of lists in Python Next Convert nested JSON to CSV in Python Share your thoughts in the comments Add Your Comment Please Login to comment...