<jupyter_start><jupyter_text>Organize recording files by site This notebook copies sound files (recordings) into the pumilio directory structure based on a csv file containing information about the time and location of recording.  Required packages pandas   Variable declarations csv_filepath – path to a csv file containing information about the time and location of each recording sound_directory – path to the directory that will contain the recordings source_directory – path to the directory containing the unorganized recordings<jupyter_code>csv_filepath = ""
sound_directory = ""
source_directory = os.path.dirname(os.path.dirname(working_directory))<jupyter_output><empty_output><jupyter_text>Import statements<jupyter_code>import pandas
import os.path
from datetime import datetime
import subprocess<jupyter_output><empty_output><jupyter_text>Organize recordings<jupyter_code>visits = pandas.read_csv(csv_filepath)
visits = visits.sort_values(by=['Time'])
visits['ID'] = visits['ID'].map('{:g}'.format)
sites = visits['ID'].drop_duplicates().dropna().as_matrix()
for site in sites:
    path = os.path.join(working_directory, str(site))
    if os.path.exists(path):
        os.rmdir(path)
    os.mkdir(path)
for index, visit in visits.iterrows():
    try:
        dt = datetime.strptime(visit['Time'], '%Y-%m-%d %X')
    except TypeError:
        print('Time was not a string, but had a value of: "{0}"'.format(visit['Time']))
        continue
    source_file = os.path.join(source_directory, dt.strftime('%Y-%m-%d'), 'converted', '{0}.flac'.format(dt.strftime('%y%m%d-%H%M%S')))
    destination_file = os.path.join(working_directory, str(visit['ID']), '{0}.flac'.format(dt.strftime('%y%m%d-%H%M%S')))
    if os.path.exists(source_file):
        subprocess.check_output(["cp", source_file, destination_file])
        print('copying {0}'.format(dt.strftime('%y%m%d-%H%M%S')))
    else:
        print('\n')
        print('{0} does not exist!'.format(dt.strftime('%y%m%d-%H%M%S')))
        print(visit['Name'])
        print('\n')
    print('\n')
    print('done')<jupyter_output>copying 160127-151500


done
copying 160217-150000


done
copying 160217-153000


done
copying 160217-160000


done
copying 160217-163000


done
copying 160217-170000


done
copying 160218-150000


done
copying 160218-160000


done
copying 160218-164500


done
copying 160218-171500


done
copying 160218-174500


done
copying 160219-143000


done
copying 160219-153000


done
copying 160219-160000


done
copying 160219-164500


done
copying 160222-140000


done
copying 160222-143000


done
copying 160222-150000


done
copying 160222-153000


done
copying 160222-160000


done
copying 160222-163000


done
copying 160223-150000


done
copying 160223-154500


done
copying 160223-161500


done
copying 160223-163000


done
copying 160223-171500


done
copying 160224-150000


done
copying 160224-153000


done
copying 160224-160000


done
copying 160224-163000


done
copying 160301-143000


done
copying 160301-145000


done
copying 160301-153000


done
copying 160301-160000


done
copying 160301[...]
{'fraction_non_alphanumeric': 0.11229773462783171, 'fraction_numerical': 0.13559870550161812, 'mean_word_length': 4.57942238267148, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '156274', 'license': 'MIT', 'n_tokens_mistral': 1411, 'n_tokens_neox': 1053, 'n_words': 258, 'path': 'utilities/Organize recordings by site.ipynb', 'repo_name': 'jacobdein/alpine-soundscapes', 'size': '3090'}