0

I have a large dataset from which a subset based on some columns' values is wanted. I want to create another database from this subset. How would I do that with sqlite3 in Python?

The column from which I want to compare to get the subset contain date in the format of YYYYMMDD e.g. 20120429. 
I want to get the observation before a certain date.

Also, how can I winsorise and calculate the average value of some columns based on another column's value?

Thanks

1
  • I recommend you create a separate question for the second part; it has nothing to do with the subject line and needs to be answered separately. Commented Jun 6, 2016 at 14:14

1 Answer 1

2

You can attach the new DB file to an already existing SQLite connection (which has your existing DB open), then simply use the appropriate insert statement to copy the rows you want, adressing the tables in the attached DB using the DB alias:

attach 'newdb.sqlite' as newdb;

-- create table goes here if necessary

insert into newdb.table
select * from table where date < ...;
Sign up to request clarification or add additional context in comments.

Comments

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.