Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import plotly.express as px
import os
import shutil
import argparse

def process_file(file_path):
df = pd.read_csv(file_path, header=None)
Expand Down Expand Up @@ -65,10 +66,19 @@ def process_file(file_path):
print(f"Summary saved to {output_dir}/battery_summary.csv")
print(f"Interactive plot saved as {output_dir}/cell_voltages_plot.html")

# Prompt user for the folder containing CSV files
folder_path = input("Enter the folder path containing CSV files: ")
def main():
parser = argparse.ArgumentParser(description="Process battery CSV files.")
parser.add_argument("path", help="Path to a single CSV file or a folder containing CSV files.")
args = parser.parse_args()

if os.path.isfile(args.path):
process_file(args.path)
elif os.path.isdir(args.path):
for file in os.listdir(args.path):
if file.endswith(".csv"):
process_file(os.path.join(args.path, file))
else:
print(f"Error: {args.path} is not a valid file or directory.")

# Process all CSV files in the specified directory
for file in os.listdir(folder_path):
if file.endswith(".csv"):
process_file(os.path.join(folder_path, file))
if __name__ == "__main__":
main()