-
Notifications
You must be signed in to change notification settings - Fork 18
script to generate csv for bulk tests #2694
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
Open
ben851
wants to merge
3
commits into
main
Choose a base branch
from
append-phone-number-script
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,74 @@ | ||||||||||
| #!/bin/bash | ||||||||||
|
|
||||||||||
| # Script to append +16135550123 to a file with auto-incrementing filename | ||||||||||
| # Usage: ./append_phone_numbers.sh [base_filename] [count] | ||||||||||
|
|
||||||||||
| # Default base filename if none provided | ||||||||||
| BASE_FILENAME="${1:-phone_numbers}" | ||||||||||
| PHONE_NUMBER="+16135550123" | ||||||||||
| # Default count if none provided, otherwise use second argument | ||||||||||
| COUNT="${2:-10000}" | ||||||||||
|
|
||||||||||
| # Function to find next available filename with timestamp | ||||||||||
| find_next_filename() { | ||||||||||
| local base="$1" | ||||||||||
| local timestamp=$(date +"%Y%m%d_%H%M") | ||||||||||
| local counter=1 | ||||||||||
| local filename | ||||||||||
|
|
||||||||||
| # First try with timestamp | ||||||||||
| filename="${base}_${timestamp}.csv" | ||||||||||
| if [[ ! -f "$filename" ]]; then | ||||||||||
| echo "$filename" | ||||||||||
| return | ||||||||||
| fi | ||||||||||
|
|
||||||||||
| # Then try with incrementing numbers if timestamp file exists | ||||||||||
| while true; do | ||||||||||
| filename="${base}_${timestamp}_${counter}.csv" | ||||||||||
| if [[ ! -f "$filename" ]]; then | ||||||||||
| echo "$filename" | ||||||||||
| return | ||||||||||
| fi | ||||||||||
| ((counter++)) | ||||||||||
| done | ||||||||||
| } | ||||||||||
|
|
||||||||||
| # Get the next available filename | ||||||||||
| FILENAME=$(find_next_filename "$BASE_FILENAME") | ||||||||||
|
|
||||||||||
| # Validate that count is a positive number | ||||||||||
| if ! [[ "$COUNT" =~ ^[0-9]+$ ]] || [ "$COUNT" -le 0 ]; then | ||||||||||
| echo "Error: Count must be a positive integer" | ||||||||||
| echo "Usage: $0 [base_filename] [count]" | ||||||||||
| echo "Example: $0 sms 50000" | ||||||||||
| exit 1 | ||||||||||
| fi | ||||||||||
|
|
||||||||||
| echo "Using filename: $FILENAME" | ||||||||||
| echo "Appending $PHONE_NUMBER to $FILENAME $COUNT times..." | ||||||||||
|
|
||||||||||
| # Add CSV header if file doesn't exist | ||||||||||
| if [[ ! -f "$FILENAME" ]]; then | ||||||||||
| echo "phone number" > "$FILENAME" | ||||||||||
| fi | ||||||||||
|
|
||||||||||
| # Use a for loop to append the phone number specified number of times | ||||||||||
| for ((i=1; i<=COUNT; i++)); do | ||||||||||
| echo "$PHONE_NUMBER" >> "$FILENAME" | ||||||||||
|
|
||||||||||
| # Show progress every 10% or every 10,000 iterations, whichever is smaller | ||||||||||
| progress_interval=$((COUNT / 10)) | ||||||||||
| if [ "$progress_interval" -gt 10000 ]; then | ||||||||||
| progress_interval=10000 | ||||||||||
| elif [ "$progress_interval" -lt 1000 ]; then | ||||||||||
| progress_interval=1000 | ||||||||||
|
Comment on lines
+64
to
+65
|
||||||||||
| elif [ "$progress_interval" -lt 1000 ]; then | |
| progress_interval=1000 | |
| elif [ "$progress_interval" -lt 1 ]; then | |
| progress_interval=1 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The hardcoded phone number should be extracted as a configurable parameter or documented as a test-specific number. This would make the script more flexible for different testing scenarios.