<commit_before>import setupMoney, os, sys, sqlite3, csv
from optparse import OptionParser

__author__ = "Tannerism"
__date__ = "$Jun 27, 2015 7:45:55 PM$"



parser = OptionParser()
parser.add_option("-s", "--setup", dest="setupPath", help="Setup the folder structure for the Money_Talks application", metavar="SETUP")

options, args = parser.parse_args()

# if the setup flag was passed it will create the necessary folder structure
if options.setupPath != None:
    print "Setting up 'Money Talks' folder structure . . ."
    setupMoney.createFolderStructure(options.setupPath)
    print "Complete: Folder structure created in " + os.path.join(options.setupPath, setupMoney.appFolder)
else:
    print "Now lets do some stuff"<commit_msg>Setup the reading in of the category, subcategory and matches csv files and then taking the contents and adding them to the database<commit_after>import setupMoney, os, sys, sqlite3, csv
from optparse import OptionParser

__author__ = "Tannerism"
__date__ = "$Jun 27, 2015 7:45:55 PM$"

dbConn = ""
dbCur = ""

def readInCsv(csvFilePath):
    rows = []
    with open(csvFilePath, 'rb') as csvFile:
        reader = csv.reader(csvFile, delimiter=",")
        header = None
        rowLen = 0
        for row in reader:
            if header == None:
                header = row
                rowLen = len(header)
                print str(rowLen)
            else:
                while len(row) < rowLen:
                    row.append('')
                rows.append(row)
                print row
    return rows

def setupDatabase():
    global dbConn, dbCur
#    dbConn = sqlite3.connect('transactions.db')
#    dbCur = dbConn.cursor()
    categories = readInCsv('categories.csv')
    subcategories = readInCsv('subcategories.csv')
    matches = readInCsv('category-transaction_matching.csv')
    os.chdir('../../.db')
    print tuple(categories)
    setupMoney.setupDatabase(categories, subcategories, matches)

parser = OptionParser()
parser.add_option("-s", "--setup", dest="setupPath", help="Setup the folder structure for the Money_Talks application", metavar="SETUP")

options, args = parser.parse_args()

# if the setup flag was passed it will create the necessary folder structure
if options.setupPath != None:
    print "Setting up 'Money Talks' folder structure . . ."
    setupMoney.createFolderStructure(options.setupPath)
    print "Complete: Folder structure created in " + os.path.join(options.setupPath, setupMoney.appFolder)
else:
    print "Now lets do some stuff"
    
    # Read in the various tables and replace the tables in the database with them
    os.chdir("C:/Users/Tannerism/Documents/Money_Talks/Expenses/Bank_Statements/setup")
    setupDatabase()
    # Read in the bank statement and start categorizing
    # Prompt user if it doesn't know where to put something
{'fraction_non_alphanumeric': 0.1003874603733709, 'fraction_numerical': 0.009158154279675942, 'mean_word_length': 3.3425076452599387, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1623765', 'n_tokens_mistral': 847, 'n_tokens_neox': 793, 'n_words': 264}