Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add script to gather CSV file #5

Merged
merged 1 commit into from
Sep 13, 2023
Merged
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
24 changes: 24 additions & 0 deletions scripts/gather_csv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (c) Microsoft Corporation
# SPDX-License-Identifier: MIT
#!/bin/bash

# Define the path where you want to search for CSV files.
search_path="$1"
# The script will append a number to the end of the prefix if the output file already exists.
output_file_prefix="$2"

# Use find to locate CSV files and loop through them
find "$search_path" -type f -name "*.csv" -print0 | while IFS= read -r -d '' csv_file; do
# Assume output file does not exist.
output_file="$output_file_prefix.csv"
# If output file already exists, append count to filename and try again.
if [ -f "$output_file" ]; then
count=2
while [ -f "$output_file" ]; do
output_file="$output_file_prefix-$count.csv"
count=$((count + 1))
done
fi
# Copy the CSV file to the output file.
cp "$csv_file" "$output_file"
done