title: Trying to use API to get data into excel
body: <p>I am trying to use an API for the first time and it has become clear I have no idea what I'm doing! For example, I am trying to get the volume of production of corn in bushels for MN from the USA quickstats database. I am attaching the code that includes my actual API key - I don't know if I shouldn't do this, but need some help. Currently, my code runs, but doesn't get it into the right format as columns are off, and it just isn't coming through right. Also, some of the data elements have commas so I'm not sure if I need to write this directly to excel or what I need to do. Here is my code - sorry this isn't the best written question but I need some guidance.</p>
  
  <pre><code>from bs4 import BeautifulSoup
  import requests
  import os, csv, sys, openpyxl
  import openpyxl 
  from openpyxl import load_workbook
  from openpyxl import Workbook
  from openpyxl.utils import get_column_letter
  import time
  import contextlib
  import itertools
  import pandas as pd
  from datetime import datetime, timedelta
  
  
  print('working')
  beginningTime=time.time()
  
  file_name = 'USDA Corn Data.csv'
  
  
  url = 'http://quickstats.nass.usda.gov/api/api_GET/?key=XXXXxxxxx&amp;source_desc=CENSUS&amp;short_desc=CORN, GRAIN - PRODUCTION, MEASURED IN BU&amp;year__GE=2012&amp;state_alpha=MN&amp;format=CSV'
  
  data = requests.get(url)
  
  soup=BeautifulSoup(data.text, "html.parser")
  
  
  ######Have no idea if this next part is necessary but wasn't sure how to get the data that was returned from BeautifulSoup to write into a dataframe
  
  soupData = []
  for i in soup:
      soupData.append(i)
  print(type(soupData))
  print(soup)
  
  df = pd.DataFrame(soupData)
  
  df.to_csv(file_name, index=False)
  </code></pre>