Exemplo n.º 1
0
def cited(out_file):

    """
    CSV with institution id, name, and citation count.
    """

    # CSV writer.
    cols = ["id", "count", "name"]
    writer = csv.DictWriter(out_file, cols)
    writer.writeheader()

    count = fn.Count(HLOM_Citation.id)

    cited = (
        Institution.select(Institution, count)
        .join(Document_Institution)
        # Join citations.
        .join(HLOM_Citation, on=(Document_Institution.document == HLOM_Citation.document))
        .group_by(Institution.id)
        .order_by(count.desc())
    )

    for inst in cited.naive():

        writer.writerow({"count": inst.count, "id": inst.id, "name": inst.metadata["Institution_Name"]})
Exemplo n.º 2
0
Arquivo: inst.py Projeto: overview/osp
def queue_geocode():

    """
    Queue geocoding tasks in the worker.

    :param in_file: A handle on the input CSV.
    """

    for inst in Institution.select():
        config.rq.enqueue(geocode, inst.id)
Exemplo n.º 3
0
def lonlats(out_file):

    """
    CSV with institution name and lon/lat, for Fusion Tables.
    """

    # CSV writer.
    cols = ["name", "longitude", "latitude"]
    writer = csv.DictWriter(out_file, cols)
    writer.writeheader()

    # Select rows with coordinates.
    geocoded = Institution.select().where(Institution.metadata.contains("Latitude"))

    for inst in geocoded:

        writer.writerow(
            {
                "name": inst.metadata["Institution_Name"],
                "longitude": inst.metadata["Longitude"],
                "latitude": inst.metadata["Latitude"],
            }
        )