getTabulatedFilenames.py 621 B

12345678910111213141516
  1. import glob, os
  2. files = []
  3. for filename in glob.iglob('./refractiveindex.info-database/database/data/**', recursive=True):
  4. if os.path.isfile(filename): # filter dirs
  5. with open(filename) as f:
  6. contents = f.read()
  7. # if contents.count('- type:')>1:
  8. # files.append(filename.replace('./refractiveindex.info-database/database/data/',''))
  9. if 'tabulated n' in contents:
  10. files.append(filename.replace('./refractiveindex.info-database/database/data/',''))
  11. print(files)
  12. print(len(files))
  13. with open('tabulated.txt', 'w') as f:
  14. f.write(str(files))