input: Write a function that parses a CSV file and generates a new CSV file with the total number of rows, total number of columns, and the sum of the data for each attribute. If the total cannot be calculated for a specific attribute, it should append 'N/A'. If the input CSV is empty, the function should return a CSV file with the header only.
  
  
  def parse_csv(filename):
      with open(filename) as csv_file:
          reader = csv.DictReader(csv_file)
          rows = 0
          cols = 0
          data_totals = {'Rows': 'N/A', 'Columns': 'N/A', 'Data Totals': 'N/A'}
          try:
              for row in reader:
                  rows += 1
                  cols = len(row)
                  for col in row:
                      if data_totals.get(col) is None:
                          data_totals[col] = float(row[col])
                      else:
                          data_totals[col] += float(row[col])
              data_totals['Rows'] = rows
              data_totals['Columns'] = cols
              data_totals['Data Totals'] = sum(data_totals.values()) - rows - cols
          except ValueError:
              data_totals['Data Totals'] = 'N/A'
  
      with open('new_csv.csv', mode='w') as new_csv_file:
          writer = csv.writer(new_csv_file, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
          writer.writerow(data_totals.keys())
          writer.writerow(data_totals.values())
  
  assert parse_csv('empty.csv')==open('new_csv.csv').read(15)==['Rows', 'Columns', 'Data Totals', 'Attr1', 'Attr2', 'Attr3']
  assert parse_csv('simple.csv')==open('new_csv.csv').read(15)==['10', '5', '150', '30', '50', '70']
  assert parse_csv('complex.csv')==open('new_csv.csv').read(15)==['20', '7', '350', '50', '70', '90', '50', '60', '30']
  assert parse_csv('error.csv')==open('new_csv.csv').read(15)==['5', '3', 'N/A', 'N/A', 'N/A', 'N/A']
  assert parse_csv('missing.csv')==open('new_csv.csv').read(15)==['7', '8', '130', '20', '30', '40', '10', '10', '10', '10']
  
output: import csv
  
  def parse_csv(filename):
      with open(filename) as csv_file:
          reader = csv.DictReader(csv_file)
          rows = 0
          cols = 0
          data_totals = {'Rows': 'N/A', 'Columns': 'N/A', 'Data Totals': 'N/A'}
          try:
              for row in reader:
                  rows += 1
                  cols = len(row)
                  for col in row:
                      if data_totals.get(col) is None:
                          data_totals[col] = float(row[col])
                      else:
                          data_totals[col] += float(row[col])
              data_totals['Rows'] = rows
              data_totals['Columns'] = cols
              data_totals['Data Totals'] = sum(data_totals.values()) - rows - cols
          except ValueError:
              data_totals['Data Totals'] = 'N/A'
  
      with open('new_csv.csv', mode='w') as new_csv_file:
          writer = csv.writer(new_csv_file, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
          writer.writerow(data_totals.keys())
          writer.writerow(data_totals.values())