title: writing nested dictionary in the csv file, but the header is getting repeated / appended for each time in csv file
body: <p>I'm newbie to python. I've coded to append nested dictionary in the csv file. but the header is also getting apended each time when I run the code. </p>
  
  <p>But I need, the header should need to be appended only once in the csv file not more than that.</p>
  
  <p>Is there any modification that you suggest which will helpful for me..</p>
  
  <p>Thanks in Advance.</p>
  
  <pre><code>                       CSV file output
  </code></pre>
  
  <p>CSV file screenshot</p>
  
  <p><a href="https://i.stack.imgur.com/4XO01.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4XO01.png" alt="enter image description here"></a></p>
  
  <pre><code>User ID Name    Age Occupation  Department  Salary  Address
  
  1100    Vishal  24  Data Scientist  Analytics   75000   No.341, Kannagi Nagar, Okkiyam Thoraipakkam, chennai 97
  
  User ID Name    Age Occupation  Department  Salary  Address
  
  1101    MuraliKrishnan  45  Painting contractor Contract    50000   No.341, Kannagi Nagar, Okkiyam thoraipakkam, chennai 97
  </code></pre>
  
  <pre><code>import csv
  
  user_details = {}
  
  while True:
      user_input = input(" You're Operation Please ( New / View ) Details : ").lower()
  
      if user_input == 'new':
          create_user_ID = input(" Enter the user ID :  ")
          user_details[create_user_ID] = {}
          user_name = input(" Enter the user name : ")
          user_details[create_user_ID]['Name'] = user_name
          user_age = int(input(" Enter the Age : "))
          user_details[create_user_ID]['Age'] = user_age
          user_occupation = input(" Enter the users occupation : ")
          user_details[create_user_ID]['Occupation'] = user_occupation
          user_department = input(" user department : ")
          user_details[create_user_ID]['Department'] = user_department
          user_income = int(input(" Enter the salary details : "))
          user_details[create_user_ID]['Salary'] = user_income
          user_address = input(" Enter the Address details ")
          user_details[create_user_ID]['Address'] = user_address
  
          print(f" New User account {create_user_ID} has been successfully created")
  
  # Need to clarify this step,but program is running without any issues
  
          with open('Employee Details.csv', 'a') as csvfile:
              csv_columns = ['User ID', 'Name', 'Age', 'Occupation', 'Department', 'Salary', 'Address']
              writer = csv.DictWriter(csvfile, fieldnames=csv_columns)
  
              writer.writeheader()
              for key,value in user_details.items():
                  row = {'User ID': key}
                  row.update(value)
                  writer.writerow(row)
  
          process = input(" Do you want to continue the Account creation process (YES / NO ) : ").lower()
          if process == 'no':
              break
  
      elif user_input == 'view':
          user_ID = input("Enter the user_ID : ")
          print(user_details[user_ID])
          break
  
      else:
          print(" Please enter the proper command to execute (new / view)")
  
  for detail in user_details.items():
      print(detail)
  </code></pre>