Skip to content

Commit

Permalink
local printout of unknown NWSLIs against csv table
Browse files Browse the repository at this point in the history
  • Loading branch information
akrherz committed Jul 13, 2017
1 parent f3dec84 commit 113c5a9
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions scripts/dbutil/xcheck_nwsli_csv.py
@@ -0,0 +1,40 @@
"""See if we have metadata in a local CSV file"""
from __future__ import print_function

import requests
import psycopg2
from pyiem.reference import nwsli2country, nwsli2state
import pandas as pd


def dowork(df, nwsli):
"""do work!"""
if nwsli not in df['NWSLI'].values:
# print("Missing %s" % (nwsli, ))
return
row = df[df['NWSLI'] == nwsli].iloc[0]
print("------")
print(row['NWSLI'])
print("%s %s%s - %s" % (row['City'], row['Mileage'], row['Direction'],
row['Station Name']))
print(row['State'])
print(row['Program Acronym'])
print(row['Latitude'])
print(row['Longitude'])


def main():
"""Go Main Go!"""
pgconn = psycopg2.connect(database='hads', host='localhost', port=5556,
user='nobody')
cursor = pgconn.cursor()
cursor.execute("""
SELECT distinct nwsli from unknown ORDER by nwsli
""")
df = pd.read_csv('/tmp/nwsli_database.csv', low_memory=False)
for row in cursor:
dowork(df, row[0])


if __name__ == '__main__':
main()

0 comments on commit 113c5a9

Please sign in to comment.