Skip to content

Instantly share code, notes, and snippets.

View Dsobh's full-sized avatar

David Sobrín Hidalgo Dsobh

View GitHub Profile
@Dsobh
Dsobh / processUsage.py
Last active December 18, 2023 09:59
Script to get CPU, memory and GPU usage. Using psutil and GPUtil. To use: python3 processUsage.py process_pid interval_in_sec output_file_name.csv
import psutil
import GPUtil
import csv
import time
import sys
def monitor_process_usage(pid, interval=1):
# csv file creation with write mode
with open('process_monitoring.csv', 'w', newline='') as csvfile:
@Dsobh
Dsobh / columnMerger.py
Created December 18, 2023 10:02
Append columns of one csv to another. Usage: python3 columnMerger.py original_file.csv secondary_file.csv mode (1 for append columns, 2 for append rows) new_file_name.csv
import pandas as pd
import sys
def append_columns(original_file, secondary_file, mode, new_file):
# Get file paths from the user
original_file_path = original_file
secondary_file_path = secondary_file
try:
@Dsobh
Dsobh / addColumn.py
Created December 18, 2023 10:04
Add a column with a single value. Useful to tag data. Usage: python3 addColumn.py file_name.csv column_name column_value
import pandas as pd
import sys
def add_column_to_csv(input_csv, column_name, column_value):
# Read the CSV file into a DataFrame
df = pd.read_csv(input_csv)
# Add a new column with the specified name and value
df[column_name] = column_value
@Dsobh
Dsobh / rosbag-info.py
Created October 16, 2025 12:04
Python Script to obtain information from ROS 2 bags located at the provided input path.
import os
import sys
import yaml
def analizar_rosbag_yaml(ruta_yaml, ruta_base):
"""
Analiza un archivo YAML de rosbag2 y devuelve estadísticas clave.
"""
try: