<commit_before>#!/usr/bin/env python3

import os
import json

def merge( basepath ):

    traces = []

    for fname in os.listdir( basepath ):
        path = os.path.join( basepath, fname )
        trace = []
        with open( path ) as f:
            for line in f:
                # print line
                try:
                    j = json.loads( line )
                    # print( j )
                    trace.append( j )
                except:
                    pass
        traces.append( trace )

    merged = []

    while len( traces ) > 0:
        earliest = ( 0, traces[ 0 ][ 0 ] )
        for i in range( 1, len( traces ) ):
            # print( len( traces[ i ] ) )
            if traces[ i ][ 0 ][ 0 ] < earliest[ 1 ][ 0 ]:
                earliest = ( i, traces[ i ][ 0 ] )
        # print( earliest[ 1 ] )
        merged.append( earliest[ 1 ] )
        traces[ earliest[ 0 ] ].pop( 0 )
        if len( traces[ earliest[ 0 ] ] ) < 1:<commit_msg>corner case<commit_after>#!/usr/bin/env python3

import os
import json

def merge( basepath ):

    traces = []

    for fname in os.listdir( basepath ):
        path = os.path.join( basepath, fname )
        trace = []
        with open( path ) as f:
            for line in f:
                # print line
                try:
                    j = json.loads( line )
                    # print( j )
                    trace.append( j )
                except:
                    pass
        if len( trace ) > 0:
            traces.append( trace )

    merged = []

    while len( traces ) > 0:
        earliest = ( 0, traces[ 0 ][ 0 ] )
        for i in range( 1, len( traces ) ):
            # print( len( traces[ i ] ) )
            if traces[ i ][ 0 ][ 0 ] < earliest[ 1 ][ 0 ]:
                earliest = ( i, traces[ i ][ 0 ] )
        # print( earliest[ 1 ] )
        merged.append( earliest[ 1 ] )
        traces[ earliest[ 0 ] ].pop( 0 )
        if len( traces[ earliest[ 0 ] ] ) < 1:
{'fraction_non_alphanumeric': 0.12379502790461694, 'fraction_numerical': 0.017757483510908167, 'mean_word_length': 1.1959910913140313, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 6, '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}}
{'dir': 'git-commits-cleaned', 'id': '4814871', 'n_tokens_mistral': 638, 'n_tokens_neox': 589, 'n_words': 192}