From f789335ade2aee2d5ee817ef7d5a631edb4b0ce5 Mon Sep 17 00:00:00 2001 From: RemDelaporteMathurin Date: Wed, 18 Sep 2024 14:20:37 -0400 Subject: [PATCH] Refactor get_time_energy_values function to allow for custom delimiter in CSV files --- libra_toolbox/neutron_detection/diamond/process_data.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libra_toolbox/neutron_detection/diamond/process_data.py b/libra_toolbox/neutron_detection/diamond/process_data.py index 8f2810e..806b986 100644 --- a/libra_toolbox/neutron_detection/diamond/process_data.py +++ b/libra_toolbox/neutron_detection/diamond/process_data.py @@ -3,7 +3,7 @@ def get_time_energy_values( - directory: str, time_column: int = 2, energy_column: int = 3 + directory: str, time_column: int = 2, energy_column: int = 3, delimiter=";" ): """From a directory of CSV files, extract the time and energy values. @@ -20,10 +20,10 @@ def get_time_energy_values( # Iterate through all CSV files in the directory for filename in os.listdir(directory): - if filename.endswith(".CSV"): + if filename.endswith(".CSV") or filename.endswith(".csv"): # Load data from the CSV file csv_file_path = os.path.join(directory, filename) - data = np.genfromtxt(csv_file_path, delimiter=";") + data = np.genfromtxt(csv_file_path, delimiter=delimiter) # print(data.shape) # print(data) # Extract and append the energy data to the list