# Path: pump/vivopump.py
# class DefNotFoundException(Exception):
# class InvalidDefException(Exception):
# class InvalidSourceException(Exception):
# class PathLengthException(Exception):
# class UnicodeCsvReader(object):
# class UnicodeDictReader(csv.DictReader):
#     class RowError(Exception):
#     def __init__(self, value):
#     def __str__(self):
#     def __init__(self, value):
#     def __str__(self):
#     def __init__(self, value):
#     def __str__(self):
#     def __init__(self, value):
#     def __str__(self):
#     def __init__(self, f, encoding="utf-8", **kwargs):
#     def __iter__(self):
#     def next(self):
#     def line_num(self):
#     def __init__(self, f, encoding="utf-8", fieldnames=None, **kwds):
# def read_csv(filename, skip=True, delimiter='|'):
# def read_csv_fp(fp, skip=True, delimiter="|"):
# def write_csv_fp(fp, data, delimiter='|'):
# def write_csv(filename, data, delimiter='|'):
# def replace_initials(s):
#     def repl_function(m):
# def key_string(s):
# def get_vivo_types(selector, parms, separator=';'):
# def get_vivo_ufid(parms):
# def get_vivo_publishers(parms):
# def get_vivo_journals(parms):
# def get_vivo_ccn(parms):
# def get_vivo_sponsorid(parms):
# def get_vivo_authors(parms):
# def get_vivo_positions(parms):
# def read_update_def(filename, prefix):
#     def make_prefix_dict(prefix_text):
#     def cast_to_rdflib(t):
#     def fixit(current_object, prefix_dictionary):
#     def add_order(a, b):
#     def validate_update_def(a):
#     def add_object_names_and_step_attributes(a):
# def add_qualifiers(input_path):
# def gather_types(input_step, varname):
# def make_update_query(entity_sparql, path):
# def make_rdf_term(row_term):
# def get_graph(update_def, query_parms):
# def new_uri(parms):
# def vivo_query(query, parms):
# def write_update_def(update_def, filename):
# def parse_pages(pages):
# def parse_date_parts(month, year):
# def get_args():
# def get_parms():
# def add_type_restriction(step):
# def make_get_query(update_def):
# def unique_path(path):
# def make_get_data(update_def, result_set):
# def make_rdf_term_from_source(value, step):
# def prepare_column_values(update_string, intra, step_def, enum, row, column_name):
# def load_enum(update_def):
# def create_enum(filename, query, parms, trim=0, skip=0):
# 
# Path: pump/pump.py
# class Pump(object):
#     def __init__(self, defn="pump_def.json", src="pump_data.txt"):
#     def __str__(self):
#     def serialize(self):
#     def summarize(self):
#     def test(self):
#     def get(self):
#     def update(self):
#     def __do_get(self):
#     def __do_merges(self, merges):
#     def __do_remove(self, row, uri):
#     def __do_update(self):
#     def __do_three_step_update(self, row, column_name, uri, path, data_update):
#     def __do_two_step_update(self, row, column_name, uri, column_def, data_update):
#     def __do_the_update(self, row, column_name, uri, step_def, column_values, vivo_objs):
#     def _get_step_triples(self, uri, step_def):
#         def step_graph(uris, pred, otype=None, graph=self.update_graph):
#         def sieve_triples(sgc, column_name):


import sys
from datetime import date
from pump.vivopump import read_csv_fp, write_csv_fp, improve_org_name
from pump.pump import __version__
#!/usr/bin/env/python

"""
    manage_columns_filter.py -- add needed columns, remove unused columns
"""

__author__ = "Michael Conlon"
__copyright__ = "Copyright 2015 (c) Michael Conlon"
__license__ = "New BSD License"
__version__ = "0.01"




data_in = read_csv_fp(sys.stdin)
var_names = data_in[data_in.keys()[0]].keys()  # create a list of var_names from the first row
print >>sys.stderr, "Columns in", var_names
data_out = {}
for row, data in data_in.items():
    new_data =dict(data)

    # Add these columns

    new_data['uri'] = ''
    new_data['remove'] = ''
    new_data['funder'] = '1'

# Path: pump/vivopump.py
# class DefNotFoundException(Exception):
# class InvalidDefException(Exception):
# class InvalidSourceException(Exception):
# class PathLengthException(Exception):
# class UnicodeCsvReader(object):
# class UnicodeDictReader(csv.DictReader):
#     class RowError(Exception):
#     def __init__(self, value):
#     def __str__(self):
#     def __init__(self, value):
#     def __str__(self):
#     def __init__(self, value):
#     def __str__(self):
#     def __init__(self, value):
#     def __str__(self):
#     def __init__(self, f, encoding="utf-8", **kwargs):
#     def __iter__(self):
#     def next(self):
#     def line_num(self):
#     def __init__(self, f, encoding="utf-8", fieldnames=None, **kwds):
# def read_csv(filename, skip=True, delimiter='|'):
# def read_csv_fp(fp, skip=True, delimiter="|"):
# def write_csv_fp(fp, data, delimiter='|'):
# def write_csv(filename, data, delimiter='|'):
# def replace_initials(s):
#     def repl_function(m):
# def key_string(s):
# def get_vivo_types(selector, parms, separator=';'):
# def get_vivo_ufid(parms):
# def get_vivo_publishers(parms):
# def get_vivo_journals(parms):
# def get_vivo_ccn(parms):
# def get_vivo_sponsorid(parms):
# def get_vivo_authors(parms):
# def get_vivo_positions(parms):
# def read_update_def(filename, prefix):
#     def make_prefix_dict(prefix_text):
#     def cast_to_rdflib(t):
#     def fixit(current_object, prefix_dictionary):
#     def add_order(a, b):
#     def validate_update_def(a):
#     def add_object_names_and_step_attributes(a):
# def add_qualifiers(input_path):
# def gather_types(input_step, varname):
# def make_update_query(entity_sparql, path):
# def make_rdf_term(row_term):
# def get_graph(update_def, query_parms):
# def new_uri(parms):
# def vivo_query(query, parms):
# def write_update_def(update_def, filename):
# def parse_pages(pages):
# def parse_date_parts(month, year):
# def get_args():
# def get_parms():
# def add_type_restriction(step):
# def make_get_query(update_def):
# def unique_path(path):
# def make_get_data(update_def, result_set):
# def make_rdf_term_from_source(value, step):
# def prepare_column_values(update_string, intra, step_def, enum, row, column_name):
# def load_enum(update_def):
# def create_enum(filename, query, parms, trim=0, skip=0):
# 
# Path: pump/pump.py
# class Pump(object):
#     def __init__(self, defn="pump_def.json", src="pump_data.txt"):
#     def __str__(self):
#     def serialize(self):
#     def summarize(self):
#     def test(self):
#     def get(self):
#     def update(self):
#     def __do_get(self):
#     def __do_merges(self, merges):
#     def __do_remove(self, row, uri):
#     def __do_update(self):
#     def __do_three_step_update(self, row, column_name, uri, path, data_update):
#     def __do_two_step_update(self, row, column_name, uri, column_def, data_update):
#     def __do_the_update(self, row, column_name, uri, step_def, column_values, vivo_objs):
#     def _get_step_triples(self, uri, step_def):
#         def step_graph(uris, pred, otype=None, graph=self.update_graph):
#         def sieve_triples(sgc, column_name):


# Path: uf_examples/sponsors/manage_columns_filter.py
import sys
from datetime import date
from pump.vivopump import read_csv_fp, write_csv_fp, improve_org_name
from pump.pump import __version__

#!/usr/bin/env/python

"""
    manage_columns_filter.py -- add needed columns, remove unused columns
"""

__author__ = "Michael Conlon"
__copyright__ = "Copyright 2015 (c) Michael Conlon"
__license__ = "New BSD License"
__version__ = "0.01"




data_in = read_csv_fp(sys.stdin)
var_names = data_in[data_in.keys()[0]].keys()  # create a list of var_names from the first row
print >>sys.stderr, "Columns in", var_names
data_out = {}
for row, data in data_in.items():
    new_data =dict(data)

    # Add these columns

    new_data['uri'] = ''
    new_data['remove'] = ''
    new_data['funder'] = '1'

    new_data['name'] = improve_org_name(new_data['SponsorName'])