#!/usr/bin/env python import sys from the_semantic_db_code import * from the_semantic_db_functions import * from the_semantic_db_processor import * C = context_list("play with shares") #file = "data/short_sp500hst.txt" file = "data/sp500hst.txt" with open(file,'r') as f: for line in f: date,ticker,open_,high,low,close,volume = line.split(',') year = date[:4] month = date[4:6] day = date[-2:] date = "date: " + year + "/" + month + "/" + day ticker = "ticker: " + ticker print(date) print(ticker) C.add_learn("","ticker: _list",ticker) C.add_learn("open",ticker,ket(date,float(open_))) C.add_learn("high",ticker,ket(date,float(high))) C.add_learn("low",ticker,ket(date,float(low))) C.add_learn("close",ticker,ket(date,float(close))) C.add_learn("volume",ticker,ket(date,float(volume))) # no point using int(volume) since ket() casts it to float anyway. print(C.dump_universe()) name = "sw-examples/shares.sw" save_sw(C,name)