jeudi 15 septembre 2016

using python and sqlite to subtract one row from the next row, then convert the answer to 1 or 0 and input the result into a different column

I am attempting to use python and sqlite to subtract one row from the next row, then convert the answer to 1 or 0 and input the result into a different column.

This is what I have so far, I think it would use a for loop and an if statement. Any help is greatly appreciated!

import sqlite3
conn = sqlite3.connect(r"C:\inputs.db")
c = conn.cursor()

##for each row in COLUMN "field1" from TABLE "test" calculate n1-n2, n2-n3, n3-n4 etc.
##if n1-n2 > 0 make a new entry into COLUMN "output".  New entry should read "1"
##if n1-n2 < 0 make a new entry into COLUMN "output".  New entry should read "0"
##proceed to n2-n3

conn.commit()

Aucun commentaire:

Enregistrer un commentaire