Untitled

 avatar
unknown
plain_text
a month ago
982 B
4
Indexable
#!/bin/bash

# Input and output CSV files
INPUT_CSV="input.csv"
OUTPUT_CSV="output.csv"

# Define function to determine if an AccountID is internal
is_internal() {
  local account_id="$1"
  # Replace this logic with your own determination logic
  if [[ "$account_id" == "123" || "$account_id" == "456" ]]; then
    echo "Internal"
  else
    echo "External"
  fi
}

# Read the input CSV, process, and write to output CSV
{
  # Read the header
  IFS=, read -r header && echo "${header},Status" > "$OUTPUT_CSV"

  # Read the rest of the file line by line
  while IFS=, read -r account_id name other_columns; do
    # Skip empty rows
    if [[ -z "$account_id" ]]; then
      continue
    fi

    # Determine if the account is internal or external
    status=$(is_internal "$account_id")

    # Append the result to the output file
    echo "$account_id,$name,$other_columns,$status" >> "$OUTPUT_CSV"
  done
} < "$INPUT_CSV"

echo "Processing completed. Output written to $OUTPUT_CSV"
Leave a Comment