Skip to content

Commit

Permalink
Refactor get_time_energy_values function to allow for custom delimite…
Browse files Browse the repository at this point in the history
…r in CSV files
  • Loading branch information
RemDelaporteMathurin committed Sep 18, 2024
1 parent 644747b commit f789335
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions libra_toolbox/neutron_detection/diamond/process_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down

0 comments on commit f789335

Please sign in to comment.