示例#1
0
 def read_next(self):
     self.result = self.cache
     self.cache = [
         read_csv(file_name_x,
                  [self.flag, (self.flag + self.range) % self.length]),
         read_csv(file_name_y,
                  [self.flag, (self.flag + self.range) % self.length])
     ]
     return self.result
示例#2
0
def test_no_extra_added_offer_status(cursor):
    query = r"""
        SELECT
            status
        FROM offer_status
    """
    db_data = sql_select(cursor, query)
    csv_data = read_csv("offer_status.csv")

    # Ensure that the categories in the CSV file and the Postgres DB are the same
    assert set(db_data) == set(csv_data)
示例#3
0
def test_no_extra_added_category(cursor):
    query = r"""
        SELECT
            id,
            name
        FROM category
    """
    db_data = sql_select(cursor, query)
    csv_data = read_csv("categories.csv")

    # Ensure that the categories in the CSV file and the Postgres DB are the same
    assert set(db_data) == set(csv_data)
db = SQLAlchemy(app)

from app import models
db.init_app(app)

from flask import session
from app.models import Federal_Territory, Party, Constituency, Result, Federal_State
from read_file import read_csv

with app.app_context():
    db.drop_all()
    db.create_all()
    federal_territory = Federal_Territory()
    party = Party()

    federal_territories = read_csv(federal_territory)
    db.session.add(federal_territories)
    db.session.commit()


@app.route('/api/federal_states', methods=['GET'])
def federal_states():

    data = []
    federal_states = Federal_State.query.all()

    for fs in federal_states:
        data.append({'id': fs.id, 'name': fs.name})

    return jsonify({'data': data})
示例#5
0
		if(existNode != None):
			recurseTree(curNode.n2, node, existNode, nodeList, k)
		elif(curNode.n2.height < k):
			innerList = []
			nodeList.append(innerList)
			recurseTree(curNode.n2, node, innerList, nodeList, k)
		else:
			recurseTree(curNode.n2, node, None, nodeList, k)

k = -1
if(len(sys.argv) > 2):
	k = float(sys.argv[2])
if(len(sys.argv) == 1 or len(sys.argv) > 3):
	print("Usage: py hclustering.py <dataset.csv> [thresh]")
	exit()
my_df = rf.read_csv()
#create a dictionary to remember data for points
numToPoint = {}
for i in range(0, len(my_df)):
	curRow = my_df.loc[i]
	curList = []
	for j in range(len(curRow)):
		if(curRow.iloc[j] != ' '):
			curList.append(curRow.iloc[j])
	numToPoint[i] = curList
listNums = list(range(len(my_df)))
minDist = 0
minI = -1
minJ = -1
firstDist = 1
edited = {}