title: Validating a Data Type in Python
body: <p>I'm pulling in a data file with key value pairs where the data is raw and starts as a string.  I created this function to pass the value of the key value pair to check what data type it is.  </p>
  
  <p>I created this function to tag that value and convert it to the appropriate datatype as needed. </p>
  
  <p>Is this the best way to handle this, or is there a library or function already included with python that's faster, or more efficient? </p>
  
  <pre><code>import dateparser
  def dataType(value):
      try: 
          int(value)
          return 'INTEGER'
      except ValueError:
          try:
              float(value)
              return 'DOUBLE'
          except ValueError:
              try:
                  if value and value[0].isdigit():
                      dateparser.parse(value, settings={'STRICT_PARSING': True})
                      return 'DATETIME'
                  else: 
                      return 'VARCHAR'
              except ValueError:
                  return 'VARCHAR'
  </code></pre>