title: AttributeError: 'dict' object has no attribute 'split'
body: <p>I am trying to run this code where data of a dictionary is saved in a separate csv file.
  Here is the dict:</p>
  
  <pre><code>body = {
          'dont-ask-for-email': 0,
          'action': 'submit_user_review',
          'post_id': 76196,
          'email': email_random(),
          'subscribe': 1,
          'previous_hosting_id': prev_hosting_comp_random(),
          'fb_token': '',
          'title': review_title_random(),
          'summary': summary_random(),
          'score_pricing': star_random(),
          'score_userfriendly': star_random(),
          'score_support': star_random(),
          'score_features': star_random(),
          'hosting_type': hosting_type_random(),
          'author': name_random(),
          'social_link': '',
          'site': '',
          'screenshot[image][]': '',
          'screenshot[description][]': '',
          'user_data_process_agreement': 1,
          'user_email_popup': '',
          'subscribe_popup': 1,
          'email_asked': 1
  }
  </code></pre>
  
  <p>Now this is the code to write in a CSV file and finally save it:</p>
  
  <pre><code>columns = []
  rows = []
  chunks = body.split('}')
  for chunk in chunks:
      row = []
      if len(chunk)&gt;1:
          entry = chunk.replace('{','').strip().split(',')
          for e in entry:
              item = e.strip().split(':')
              if len(item)==2:
                  row.append(item[1])
                  if chunks.index(chunk)==0:
                      columns.append(item[0])
          rows.append(row)
  df = pd.DataFrame(rows, columns = columns)
  df.head()
  
  df.to_csv ('r3edata.csv', index = False, header = True)
  </code></pre>
  
  <p>but this is the error I get:</p>
  
  <pre><code>Traceback (most recent call last):
    File "codeOffshoreupdated.py", line 125, in &lt;module&gt;
      chunks = body.split('}')
  AttributeError: 'dict' object has no attribute 'split'
  </code></pre>
  
  <p>I know that dict has no attribute named split but how do I fix it?</p>
  
  <p>Edit:
  format of the CSV I want:</p>
  
  <pre><code>dont-ask-for-email, action, post_id, email, subscribe, previous_hosting_id, fb_token, title, summary, score_pricing, score_userfriendly, score_support, score_features, hosting_type,author, social_link, site, screenshot[image][],screenshot[description][],user_data_process_agreement,user_email_popup,subscribe_popup,email_asked
  0,'submit_user_review',76196,email_random(),1,prev_hosting_comp_random(),,review_title_random(),summary_random(),star_random(),star_random(),star_random(),star_random(),hosting_type_random(),name_random(),,,,,1,,1,1
  </code></pre>
  
  <p>Note: all these functions mentioned are return values</p>
  
  <p>Edit2:</p>
  
  <p>I am picking emails from the email_random() function like this:</p>
  
  <pre><code>def email_random():
          with open('emaillist.txt') as emails:
                  read_emails = csv.reader(emails, delimiter = '\n')
                  return random.choice(list(read_emails))[0]
  </code></pre>
  
  <p>and the emaillist.txt is like this:</p>
  
  <pre><code>xyz@gmail.com
  xya@gmail.com
  xyb@gmail.com
  xyc@gmail.com
  xyd@gmail.com 
  </code></pre>
  
  <p>other functions are also picking the data from the files like this too.</p>