Advertisement
mayankjoin3

Gather system information

Feb 10th, 2025
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | None | 0 0
  1. import csv
  2. import platform
  3. import psutil
  4.  
  5. # Gather system information
  6. system_info = {
  7.     "OS": platform.system(),
  8.     "OS Version": platform.version(),
  9.     "Architecture": platform.architecture()[0],
  10.     "Processor": platform.processor(),
  11.     "CPU Cores": psutil.cpu_count(logical=False),
  12.     "Logical CPUs": psutil.cpu_count(logical=True),
  13.     "RAM (GB)": round(psutil.virtual_memory().total / (1024**3), 2),
  14.     "Disk Space (GB)": round(psutil.disk_usage('/').total / (1024**3), 2)
  15. }
  16.  
  17. # Define CSV file name
  18. csv_filename = "hardware_specs.csv"
  19.  
  20. # Write to CSV
  21. with open(csv_filename, mode='w', newline='') as file:
  22.     writer = csv.writer(file)
  23.     writer.writerow(["Component", "Specification"])
  24.     for key, value in system_info.items():
  25.         writer.writerow([key, value])
  26.  
  27. print(f"Hardware specs exported to {csv_filename}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement