<commit_before>import os
import re

root_folder = os.path.dirname(os.path.abspath(__file__))
scene_list = []
for rootdir, dirnames, filenames in os.walk(root_folder):
    for filename in filenames:
        if re.match(r'.*_MTL\.txt', filename, re.IGNORECASE) is not None:
            with open(os.path.join(rootdir, filename), 'r') as f:
                d = {}
                for line in f.read().splitlines():
                    for parameter in ['LANDSAT_PRODUCT_ID', 'DATE_ACQUIRED', 'SPACECRAFT_ID',
                                      'CLOUD_COVER_LAND', 'GRID_CELL_SIZE_PANCHROMATIC', 'GRID_CELL_SIZE_REFLECTIVE']:
                        if parameter in line:
                            d[parameter] = line.split('=')[1].strip()
                print(d)<commit_msg>stable_version<commit_after>import os
import re

root_folder = os.path.dirname(os.path.abspath(__file__))
out_dir = root_folder

parameter_list = ['LANDSAT_PRODUCT_ID', 'DATE_ACQUIRED', 'SPACECRAFT_ID',
                  'CLOUD_COVER_LAND', 'GRID_CELL_SIZE_PANCHROMATIC', 'GRID_CELL_SIZE_REFLECTIVE']

scene_list = []
for rootdir, dirnames, filenames in os.walk(root_folder):
    for filename in filenames:
        if re.match(r'.*_MTL\.txt', filename, re.IGNORECASE) is not None:
            with open(os.path.join(rootdir, filename), 'r') as f:
                d = {}
                for line in f.read().splitlines():
                    for parameter in parameter_list:
                        if parameter in line:
                            d[parameter] = line.split('=')[1].strip()
            scene_list.append(d)
# sorting list of dictionaries by LANDSAT_PRODUCT_ID key
sorted_scene_list = sorted(scene_list, key=lambda k: k['LANDSAT_PRODUCT_ID'])
with open(os.path.join(out_dir, 'scene_info.txt'), 'w') as of:
    csv_list = []
    header = parameter_list
    of.write(', '.join(parameter_list) + '\n')
    for scene in sorted_scene_list:
        of.write(', '.join(
            [scene[parameter] for parameter in
             parameter_list]) + '\n')

{'fraction_non_alphanumeric': 0.12205882352941176, 'fraction_numerical': 0.000980392156862745, 'mean_word_length': 2.4130434782608696, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3418282', 'n_tokens_mistral': 682, 'n_tokens_neox': 659, 'n_words': 141}