def _parse_files(self, msp_pth, chunk, db_type, celery_obj=False):
        """Parse the MSP files and insert into database

        Args:
            msp_pth (str): path to msp file or directory [required]
            db_type (str): The type of database to submit to (either 'sqlite', 'mysql' or 'django_mysql') [required]
            chunk (int): Chunks of spectra to parse data (useful to control memory usage) [required]
            celery_obj (boolean): If using Django a Celery task object can be used to keep track on ongoing tasks
                              [default False]
        """

        if os.path.isdir(msp_pth):
            c = 0
            for folder, subs, files in sorted(os.walk(msp_pth)):
                for msp_file in sorted(files):
                    msp_file_pth = os.path.join(folder, msp_file)
                    if os.path.isdir(msp_file_pth) or not msp_file_pth.lower().endswith(('txt', 'msp')):
                        continue
                    print('MSP FILE PATH', msp_file_pth)

                    self.num_lines = line_count(msp_file_pth)
                    # each file is processed separately but we want to still process in chunks so we save the number
                    # of spectra currently being processed with the c variable
                    with open(msp_file_pth, "r") as f:
                        c = self._parse_lines(f, chunk, db_type, celery_obj, c)
        else:
            self.num_lines = line_count(msp_pth)
            with open(msp_pth, "r") as f:
                self._parse_lines(f, chunk, db_type, celery_obj)

        self.insert_data(remove_data=True, db_type=db_type)