def load_data(self):
        folder_path = 'history_log'
        lock_path = 'history_log.lock'
        temp_file_path = 'history_log_temp.txt'
        lock = FileLock(lock_path)

        def is_older_than_180_days(date_str):
            date_format = "%Y-%m-%d"
            try:
                date_obj = datetime.strptime(date_str, date_format)
                return date_obj < datetime.now() - timedelta(days=180)
            except ValueError:
                return True

        try:
            with lock.acquire(timeout=5):  # Wait up to 5 seconds for the lock
                files_to_process = []
                for filename in os.listdir(folder_path):
                    if filename.endswith(".txt") and is_older_than_180_days(filename[:10]):  # filename[:10] is the date part
                        files_to_process.append(os.path.join(folder_path, filename))

                lines = []
                for file_path in files_to_process:
                    with open(file_path, 'r', encoding='utf-8') as file:
                        lines.extend(file.readlines())

                lines_before_cleanup = len(lines)
                lines_after_cleanup = 0
                removed_dates = set()
                with open(temp_file_path, 'w', encoding='utf-8') as temp_file:
                    for line in lines:
                        parts = line.strip().split('|')
                        if len(parts) >= 11:
                            end_offline_date_str = parts[6]  # parts[6] is online_date in 'YYYY-MM-DD' format
                            if is_older_than_180_days(end_offline_date_str):
                                removed_dates.add(end_offline_date_str)
                            else:
                                temp_file.write(line)
                                lines_after_cleanup += 1

                del lines  # Remove reference to lines
                if os.path.exists(temp_file_path):
                    try:
                        os.replace(temp_file_path, os.path.join(folder_path, 'history_all.txt'))
                    except Exception as e:
                        print(f"Error during file replacement: {e}")
                        return
                else:
                    print(f"Temporary file {temp_file_path} does not exist.")
                    return

            # Retrieve user inputs for filtering
            start_date = self.start_date_edit.date().toPyDate()  # Returns a datetime.date object
            end_date = self.end_date_edit.date().toPyDate()      # Returns a datetime.date object
            status_filter = self.status_filter.currentText()
            hostname_filter = self.hostname_edit.text().strip().lower()

            # Parse the duration filter
            user_input_duration = self.duration_edit.text().strip()
            if user_input_duration.isdigit():
                duration_filter = self.convert_to_seconds(user_input_duration)
            else:
                duration_filter = None  # If invalid, don't filter on duration

            rows = []
            with open(os.path.join(folder_path, 'history_all.txt'), 'r', encoding='utf-8') as file:
                for line in file:
                    parts = line.strip().split('|')
                    if len(parts) >= 11:
                        # Parse end_offline_date_str into a datetime.date object
                        try:
                            end_offline_date_str = parts[6]  # online_date
                            end_offline_date = datetime.strptime(end_offline_date_str, '%Y-%m-%d').date()
                        except ValueError:
                            continue  # Skip this line if date can't be parsed

                        # Check if the end_offline_date is within the selected date range
                        if start_date <= end_offline_date <= end_date:
                            # Apply status filter
                            if status_filter == 'All' or parts[9] == status_filter:
                                # Apply hostname filter
                                hostname = parts[2]
                                if hostname_filter == "" or hostname_filter.lower() in hostname.lower():
                                    # Convert duration from the file to seconds for comparison
                                    duration_str = parts[8]
                                    duration = self.convert_to_seconds(duration_str)
                                    if duration_filter is None or (duration is not None and duration >= duration_filter):
                                        start_offline = f"{parts[4]} {parts[5]}"  # start_date and start_time_str
                                        end_offline = f"{parts[6]} {parts[7]}"    # online_date and online_time_str
                                        rows.append([hostname, parts[3], start_offline, end_offline, duration_str, parts[9], parts[10]])

            rows.reverse()  # To show latest entries first

            # Set up table widget
            self.table_widget.setRowCount(len(rows))
            self.table_widget.setColumnCount(7)
            self.table_widget.setHorizontalHeaderLabels(['Hostname', 'Storename', 'Start Offline', 'End Offline', 'Duration', 'Status', 'Comment'])
            for row_idx, (hostname, storename, start_offline, end_offline, duration, status, comment) in enumerate(rows):
                self.table_widget.setItem(row_idx, 0, QTableWidgetItem(hostname))
                self.table_widget.setItem(row_idx, 1, QTableWidgetItem(storename))
                self.table_widget.setItem(row_idx, 2, QTableWidgetItem(start_offline))
                self.table_widget.setItem(row_idx, 3, QTableWidgetItem(end_offline))
                self.table_widget.setItem(row_idx, 4, QTableWidgetItem(duration))
                self.table_widget.setItem(row_idx, 5, QTableWidgetItem(status))
                self.table_widget.setItem(row_idx, 6, QTableWidgetItem(comment))
            self.table_widget.verticalHeader().setVisible(False)
            # Update status bar
            total_count = len(rows)
            wan_down_count = sum(1 for row in rows if row[5] == 'WAN down')
            server_down_count = sum(1 for row in rows if row[5] == 'Server down')
            self.status_bar.showMessage(f"Total: {total_count} | WAN down: {wan_down_count} | Server down: {server_down_count}")

        except Timeout:
            print("Failed to acquire file lock")
        except Exception as e:
            print(f"An error occurred: {e}")

i got duplicate data in history_all.txt, just merge file not include history_all.txt