input: Write a function to compute the average salary from a given CSV file containing a list of people and their salaries. If the file is empty or contains no salary data, return 0.
  
  import csv
  
  def get_average_salary(filename):
    total = 0
    count = 0
  
    try:
      with open(filename, 'r') as csvfile:
        csvreader = csv.reader(csvfile)
        next(csvreader) # skip header
  
        # loop through the CSV rows
        for row in csvreader:
          try:
            total += int(row[1])
            count += 1
          except (IndexError, ValueError):
            continue # skip rows without valid salary data
  
    except FileNotFoundError:
      return 0
    
    return total / (count or 1) # avoid division by zero
  
  # assert tests
  assert get_average_salary('salary.csv') == 2000.0
  assert get_average_salary('empty.csv') == 0
  assert get_average_salary('invalid_data.csv') == 0
  
output: def get_average_salary(filename):
    total = 0
    count = 0
  
    try:
      with open(filename, 'r') as csvfile:
        csvreader = csv.reader(csvfile)
        next(csvreader) # skip header
  
        # loop through the CSV rows
        for row in csvreader:
          try:
            total += int(row[1])
            count += 1
          except (IndexError, ValueError):
            continue # skip rows without valid salary data
  
    except FileNotFoundError:
      return 0
    
    return total / (count or 1) # avoid division by zero