0

I have a csv TABLE with data which looks like below:

    IMPORT_ID   IMPORT_AVA  EXPORT_ID   EXPORT_AVA  DIS1 DIS2
    SI1440834   2/18/2015   SI1313709   2/20/2015   140 51
    SI1440974   2/18/2015   SI1313709   2/20/2015   1   260
    SI1441006   11/29/2014  SI1313709   12/4/2014   3   252
    SI1440874   12/17/2014  SI1313721   12/20/2014  19  219
    SI1440997   1/15/2015   SI1313721   1/17/2015   3   249
    SI1440672   2/17/2015   SI1313722   2/21/2015   65  174
    SI1440997   2/24/2015   SI1313722   2/24/2015       
    SI1440874   11/14/2014  SI1313722   11/18/2014  16  232
    SI1440834   1/30/2015   SI1313722   2/4/2015        

I want to do query-

SELECT EXPORT_ID, IMPORT_ID, DIS1, DIS2, IMPORT_AVA
INTO EX_P_TEMP
FROM TABLE;

I tried to query on a sample data by using module sqlite3 but it didn't work out. Also, it didn't allow me to import csv file. How do I do it? Can I get the new table EX_P_TEMP in CSV format?

Karvy1
  • 959
  • 6
  • 14
  • 25
  • 1
    CSV isn't SQLite. Python has a [dedicated module](https://docs.python.org/2/library/csv.html) for CSV files. – Tupteq Jul 06 '15 at 00:24
  • I'm not sure that what you want to do is possible. Two options I think of are: 1) insert the csv into a database table, then do whatever select statement you want 2) load the csv into a pandas dataframe and again select. See links: http://stackoverflow.com/a/10154650/4663466, http://stackoverflow.com/a/14365647/4663466 – Scott Jul 06 '15 at 02:42
  • Use [Pandas](http://pandas.pydata.org/) is you want to use SQL-like queries on CSV tables. –  Feb 16 '16 at 00:54

0 Answers0