this code can display data
    def load_data(self):
        file_path = 'history_online.txt'
        lock_path = 'history_online.lock'
        temp_file_path = 'history_online_temp.txt'
        lock = FileLock(lock_path)
        def is_older_than_180_days(date_str):
            date_format = "%Y-%m-%d"
            try:
                date = datetime.strptime(date_str, date_format)
                return date < datetime.now() - timedelta(days=180)
            except ValueError:
                return True
        try:
            with lock.acquire(timeout=5):  # Wait up to 5 seconds for the lock
                if not os.path.exists(file_path):
                    return
                lines_before_cleanup = 0
                lines_after_cleanup = 0
                removed_dates = set()

                with open(file_path, 'r', encoding='utf-8') as file:
                    lines_before_cleanup = sum(1 for _ in file)
                
                with open(file_path, 'r', encoding='utf-8') as file, open(temp_file_path, 'w', encoding='utf-8') as temp_file:
                    for line in file:
                        parts = line.strip().split('|')
                        if len(parts) >= 11:
                            end_offline_str = f"{parts[6]} {parts[7]}"
                            end_offline_date = end_offline_str.split()[0]  # Extract just the date part (YYYY-MM-DD)
                            if is_older_than_180_days(end_offline_date):
                                removed_dates.add(end_offline_date)
                            else:
                                temp_file.write(line)
                                lines_after_cleanup += 1

                # Replace old file with cleaned file
                os.replace(temp_file_path, file_path)

                if lines_before_cleanup != lines_after_cleanup:
                    removed_dates = sorted(removed_dates)  # Sort dates for clarity
                    for date in removed_dates:
                        print(f"Removed date {date} : {lines_before_cleanup - lines_after_cleanup} lines of data older than 180 days.")

                start_date = self.start_date_edit.date().toString("yyyy-MM-dd")
                end_date = self.end_date_edit.date().toString("yyyy-MM-dd")
                status_filter = self.status_filter.currentText()
                hostname_filter = self.hostname_edit.text().strip()
                
                # 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)  # Assume user input is in minutes
                else:
                    duration_filter = None  # If invalid, don't filter on duration

                rows = []
                with open(file_path, 'r', encoding='utf-8') as file:
                    for line in file:
                        parts = line.strip().split('|')
                        if len(parts) >= 11:
                            end_offline_str = f"{parts[6]} {parts[7]}"
                            end_offline_date = end_offline_str.split()[0]  # Extract just the date part (YYYY-MM-DD)

                            # 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
                                    if hostname_filter == "" or hostname_filter.lower() in parts[2].lower():
                                        # Convert duration from the file to seconds for comparison
                                        try:
                                            duration = self.convert_to_seconds(parts[8])  # Extract duration from the line
                                        except ValueError:
                                            duration = None
                                        
                                        if duration_filter is None or (duration is not None and duration >= duration_filter):
                                            rows.append([parts[2], parts[3], f"{parts[4]} {parts[5]}", end_offline_str, parts[8], 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")

but new one code no data
    def load_data(self):
        file_path = 'history_online.txt'
        lock_path = 'history_online.lock'
        temp_file_path = 'history_online_temp.txt'
        lock = FileLock(lock_path)
        def is_older_than_180_days(date_str):
            date_format = "%Y-%m-%d"
            try:
                date = datetime.strptime(date_str, date_format)
                return date < datetime.now() - timedelta(days=180)
            except ValueError:
                return True
        try:
            with lock.acquire(timeout=5):  # Wait up to 5 seconds for the lock
                if not os.path.exists(file_path):
                    return
                with open(file_path, 'r', encoding='utf-8') as file:
                    lines = 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_str = f"{parts[6]} {parts[7]}"
                            end_offline_date = end_offline_str.split()[0]  # Extract just the date part (YYYY-MM-DD)
                            if is_older_than_180_days(end_offline_date):
                                removed_dates.add(end_offline_date)
                            else:
                                temp_file.write(line)
                                lines_after_cleanup += 1
                del lines  # Remove reference to lines
                time.sleep(0.1)  # Short delay to ensure system releases file handles
                try:
                    os.remove(file_path)
                    os.rename(temp_file_path, file_path)
                except PermissionError as e:
                    print(f"PermissionError during file replacement: {e}")
                    return

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