title: Efficient way of specifying data type when importing .csv file to SQLite Table using Python?
body: <p>I am importing data from a .csv file with headers into a SQLite table. This is easy to do of course and I could simply do the following:</p>
  
  <pre><code>sqlite&gt; .separator ","
  sqlite&gt; .import 2015.csv tennisresults2015
  </code></pre>
  
  <p>However if I do this then all the columns default to the 'TEXT' data type.  Instead I want my numeric field to default to either the 'INTEGER' or 'REAL' data types, which ever is appropriate.</p>
  
  <p>Now I realize I can define each column explicitly in Python when I create a table via the following lines of code:</p>
  
  <pre><code>conn = sqlite3.connect('tennisresults.db') #connection
  c = conn.cursor()  #get a cursor object, all SQL commands are processed by it            
  c.execute('CREATE TABLE tennisresults2015(ATP INTEGER, Location TEXT, Tournament TEXT)') #etc
  </code></pre>
  
  <p>However this .csv file has a lot of columns, as you can see from the first two lines of the file shown below:</p>
  
  <pre><code>ATP,Location,Tournament,Date,Series,Court,Surface,Round,Best of,Winner,Loser,WRank,LRank,WPts,LPts,W1,L1,W2,L2,W3,L3,W4,L4,W5,L5,Wsets,Lsets,Comment,B365W,B365L,EXW,EXL,LBW,LBL,PSW,PSL,MaxW,MaxL,AvgW,AvgL
  1,Brisbane,Brisbane International,01/05/2015,ATP250,Outdoor,Hard,1st Round,3,Duckworth J.,Simon G.,125,21,430,1730,6,2,6,2,,,,,,,2,0,Completed,4.5,1.18,4.3,1.2,4.33,1.2,4.67,1.23,4.73,1.23,4.31,1.2
  </code></pre>
  
  <p>I was wondering if there is a more efficient way of doing this instead of me manually specifying each field name and data type in Python?</p>