Exemplo n.º 1
0
def make_file(title, filename, stids, prid):
    expires = dt.date.today() + dt.timedelta(days=1)
    where = ""
    part = " or sample_date>01.01.1990 and sample_date<01.01.2017 and project_id=" + str(
        prid)

    for p in params:
        where = where + part + " and " + p

    data = {
        "Expires":
        expires.strftime('%Y.%m.%d'),
        "Title":
        title,
        "Files": [{
            "Filename": filename,
            "ContentType": "application/vnd.ms-excel"
        }],
        "Definition": {
            "Format": "excel",
            "StationIds": stids,
            "DataWhere": where[4:]
        }
    }
    resp = am.createDatafile(token, data)
    return resp["Id"]
Exemplo n.º 2
0
def make_file(title, filename, stids, datatype, prid) :
    """
    Creates an Excel file with the given station-ids.
    The data are further narrowed by the datatype and project-id.
    The time period is fixed at 1990 - 2016
    :param title: Title to use in Eksport
    :param filename: Filename to use in Eksport
    :param stids: The station-ids to extract
    :param datatype: The datatype to use in the query
    :param prid: The project-id to use in the query
    :return: Id of archive in Eksport
    """
    expires = dt.date.today() + dt.timedelta(days=1)

    where = "sample_date>01.01.1990 and sample_date<01.01.2017 and datatype=" + datatype + \
            " and project_id=" + str(prid)

    data = {
        "Expires": expires.strftime('%Y.%m.%d'),
        "Title": title,
        "Files": [{
            "Filename": filename,
            "ContentType": "application/vnd.ms-excel"}],
        "Definition": {
            "Format": "excel",
            "StationIds": stids,
            "DataWhere": where
        }
    }
    resp = am.createDatafile(token, data)
    return resp["Id"]
Exemplo n.º 3
0
def make_shapefile(title, filename, stationids, where):
    data = {
        "Expires": expires.strftime("%Y.%m.%d"),
        "Title": title,
        "Files": [{
            "Filename": filename,
            "ContentType": "application/zip"
        }],
        "Definition": {
            "Format": "shape",
            "StationIds": stationids,
            "DataWhere": where
        },
    }
    resp = am.createDatafile(token, data)
    return resp["Id"]
Exemplo n.º 4
0
def make_file(title, filename, stationid, datatype) :
    where = "sample_date>=" + datetime.datetime.strftime(fromDate, '%d.%m.%Y') \
            + " and sample_date<" + datetime.datetime.strftime(toDate, '%d.%m.%Y') \
            + " and datatype=" + datatype

    data = {
        "Expires": expires.strftime('%Y.%m.%d'),
        "Title": title,
        "Files":[{
            "Filename": filename,
            "ContentType":"text/csv"}],
        "Definition":{
            "Format":"csv",
            "StationIds": [ stationid ],
            "DataWhere": where
        }
    }
    resp = am.createDatafile(token, data)
    return resp["Id"]
Exemplo n.º 5
0
import datetime

#am.host = "http://localhost:59265"
#am.aqua_site = ""
#am.archive_site = ""

#am.host = "https://test-aquamonitor.niva.no/"

where = "project_id=12428"
title = "DuPont"
filename = "dupont.xlsx"

expires = datetime.date.today() + datetime.timedelta(days=1)

token = am.login()

data = {
    "Expires": expires.strftime('%Y.%m.%d'),
    "Title": title,
    "Files": [{
        "Filename": filename,
        "ContentType": "application/vnd.ms-excel"
    }],
    "Definition": {
        "Format": "excel",
        "StationIds": [71674, 71675, 71676, 71672, 71673],
        "DataWhere": where
    }
}
print(am.createDatafile(token, data))