Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python open directory and read files

#It doesn't have to be the current directory you can list them in any path you want:
path = '/some/path/to/file'
for filename in glob.glob(os.path.join(path, '*.txt')):
   with open(os.path.join(os.getcwd(), filename), 'r') as f: # open in readonly mode
      # do your stuff
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #open #directory #read #files
ADD COMMENT
Topic
Name
3+5 =