Displays the contents of the specified CSV file using Rich for enhanced visualization.
(self, file_path)
| 891 | self.logger.error(f"Error in update_netkb: {e}") |
| 892 | |
| 893 | def display_csv(self, file_path): |
| 894 | """ |
| 895 | Displays the contents of the specified CSV file using Rich for enhanced visualization. |
| 896 | """ |
| 897 | if not Table or not self.console: |
| 898 | return |
| 899 | with self.lock: |
| 900 | try: |
| 901 | table = Table(title=f"Contents of {file_path}", show_lines=True) |
| 902 | with open(file_path, 'r') as file: |
| 903 | reader = csv.reader(file) |
| 904 | headers = next(reader) |
| 905 | for header in headers: |
| 906 | table.add_column(header, style="cyan", no_wrap=True) |
| 907 | for row in reader: |
| 908 | formatted_row = [Text(cell, style="green bold") if cell else Text("", style="on red") for cell in row] |
| 909 | table.add_row(*formatted_row) |
| 910 | self.console.print(table) |
| 911 | except Exception as e: |
| 912 | self.logger.error(f"Error in display_csv: {e}") |
| 913 | |
| 914 | def get_network(self): |
| 915 | """ |