<commit_before>import os
import re
import struct
from datetime import datetime
import numpy as np
from aston.cache import cache
from aston.trace import Chromatogram
from aston.tracefile import TraceFile


def string_read(f):
    return f.read(struct.unpack('>B', f.read(1))[0]).decode('ascii').strip()


class AgilentMWD(TraceFile):
    mime = 'application/vnd-agilent-chemstation-mwd'
    traces = ['#uv']

    @property
    def data(self):
        print(self.filename)
        # Because the spectra are stored in several files in the same
        # directory, we need to loop through them and return them together.
        ions = []
        dtraces = []
        foldname = os.path.dirname(self.filename)
        # if foldname == '': foldname = os.curdir
        for i in [os.path.join(foldname, i) for i in
                  os.listdir(foldname)]:
            if i[-3:].upper() == '.CH':
                wv, dtrace = self._read_ind_file(i)<commit_msg>modified string read to work with our UV files.<commit_after>import os
import re
import struct
from datetime import datetime
import numpy as np
from aston.cache import cache
from aston.trace import Chromatogram
from aston.tracefile import TraceFile


def string_read(f):
    """modified string read method which works with our UV files"""
    # todo figure out why there is a null character between every value
    #   - check if this is true across all cases
    #   - if so, does this affect the interpretation of intensity values
    # it's not pretty, but it works
    read_len = struct.unpack(  # determine length to read
        '>B', f.read(1)
    )[0]
    out = f.read(  # read values, decode, and strip
        2 * read_len - 1
    ).decode('ascii').strip()
    return out.replace('\x00', '')


class AgilentMWD(TraceFile):
    mime = 'application/vnd-agilent-chemstation-mwd'
    traces = ['#uv']

    @property
    def data(self):
        print(self.filename)
        # Because the spectra are stored in several files in the same
        # directory, we need to loop through them and return them together.
        ions = []
        dtraces = []
        foldname = os.path.dirname(self.filename)
        # if foldname == '': foldname = os.curdir
        for i in [os.path.join(foldname, i) for i in
                  os.listdir(foldname)]:
            if i[-3:].upper() == '.CH':
                wv, dtrace = self._read_ind_file(i)
{'fraction_non_alphanumeric': 0.10401002506265664, 'fraction_numerical': 0.004177109440267335, 'mean_word_length': 2.5692995529061102, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2986659', 'n_tokens_mistral': 718, 'n_tokens_neox': 692, 'n_words': 244}