fix(data): ensure output directories are created before saving files #36
@@ -36,6 +36,7 @@ def create_damage_files(base_path, output_base, prefix):
|
||||
print(f"Creating {output_file_1} from taking zzz{prefix}D{file_index}.TXT")
|
||||
print("Taking datetime column on index 0...")
|
||||
print(f"Taking `{top_sensor}`...")
|
||||
os.makedirs(os.path.dirname(output_file_1), exist_ok=True)
|
||||
df[['Time', top_sensor]].to_csv(output_file_1, index=False)
|
||||
print(Fore.GREEN + "Done")
|
||||
|
||||
@@ -44,6 +45,7 @@ def create_damage_files(base_path, output_base, prefix):
|
||||
print(f"Creating {output_file_2} from taking zzz{prefix}D{file_index}.TXT")
|
||||
print("Taking datetime column on index 0...")
|
||||
print(f"Taking `{bottom_sensor}`...")
|
||||
os.makedirs(os.path.dirname(output_file_2), exist_ok=True)
|
||||
df[['Time', bottom_sensor]].to_csv(output_file_2, index=False)
|
||||
print(Fore.GREEN + "Done")
|
||||
print("---")
|
||||
@@ -58,8 +60,8 @@ def main():
|
||||
prefix = sys.argv[3] # Define output directory
|
||||
|
||||
# Create output folders if they don't exist
|
||||
for i in range(1, 5):
|
||||
os.makedirs(os.path.join(output_base, f'DAMAGE_{i}'), exist_ok=True)
|
||||
# for i in range(1, 7):
|
||||
# os.makedirs(os.path.join(output_base, f'DAMAGE_{i}'), exist_ok=True)
|
||||
|
||||
create_damage_files(base_path, output_base, prefix)
|
||||
print(Fore.YELLOW + Style.BRIGHT + "All files have been created successfully.")
|
||||
|
||||
Reference in New Issue
Block a user