1

I have imported testdata.csv file onto datascientistworkbench, and i was trying to excute sql statement on this csv file by writing codes on Ipython notebook. I did find the following .py and had it installed into Ipython notebook, but to be honest i dont know what to do next. Here is what I have installed so far:

           !pip install querycsv

Based on the description of using this querycsv.py from this link, the next step i should be doing in the normal python environment/software is this:

           querycsv.py -i testdata.csv "select distinct IPID from testdata;"

But i guess i cannot just simply copy and paste the above code into IPython notebook. Any advice? Many thanks!

8
  • 1
    I recommend reading the file in as a CSV, inserting data into SQLite database, then querying database Commented Apr 5, 2016 at 14:47
  • @openwonk thx! but i dont know how to do it, is it possible to "inserting data into SQLite database" by writing codes in IPython notebook? Commented Apr 5, 2016 at 15:32
  • @openwonk i mean after I have read the file as CSV, i am just wondering how to "insert data into SQLite database", i have been googling about it but i got confused. thx for ur help! Commented Apr 5, 2016 at 15:33
  • That querycsv.py command is meant to be run at the command line, not in Python code. You can run command line commands in IPython with the ! prefix, but then you don't get structured data to use elsewhere in the code. Commented Apr 5, 2016 at 16:47
  • Not familiar with that package, but I'm sure that it works as intended. I would trust @Thomas K suggestions. If you want to write it in raw Python, use the csv package to load and parse data, then use the sqlite3 package to load into a database. Commented Apr 5, 2016 at 17:44

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.