Ejemplo n.º 1
0
treat_feed = spr_client.get_list_feed(config.get('cscap', 'treatkey'), 'od6')
meta_feed = spr_client.get_list_feed(config.get('cscap', 'metamaster'), 'od6')

treatments, treatment_names = util.build_treatments(treat_feed)

"""
Okay, we are cross product TIL x ROT x DWN x NIT
"""

headers = ['UniqueID', 'Rep', 'Tillage', 'Rotation', 'Drainage', 
           'Nitrogen', 'Landscape','My ID']

for entry in meta_feed.entry:
    data = entry.to_dict()
    sitekey = data.get('uniqueid').lower()
    if data.get('keyspread') is not None:
        continue
    leadpi = data.get('leadpi')
    colfolder = data.get('colfolder')
    collect = docs_client.get_resource_by_id(colfolder)
    
    # Figure out how many 
    rows = []
    trt = treatments[sitekey]
    for k in ['TIL','ROT','DWM','NIT','LND']:
        if len(trt[k]) > 1:
            trt[k].remove(None)
            
    for till in trt['TIL']:
        for rot in trt['ROT']:
"""
Okay, we are cross product TIL x ROT x DWN x NIT
"""

headers = ['UniqueID', 'Rep', 'Tillage', 'Rotation', 'Drainage',
           'Nitrogen', 'Landscape', 'My ID']


def get_just_code(text):
    if text == '':
        return ''
    return text.split()[0]

for entry in meta_feed.entry:
    data = entry.to_dict()
    sitekey = data.get('uniqueid').lower()
    if sitekey is None:
        continue
    print sitekey
    leadpi = data.get('leadpi')
    pi_spreadsheet = spr_client.get_list_feed(data.get('keyspread'), 'od6')
    current_entries = []
    for le in pi_spreadsheet.entry:
        row = le.to_dict()
        for key in row:
            if row[key] is None:
                row[key] = ''
        key = "%s||%s||%s||%s||%s||%s" % (
                    get_just_code(row.get('tillage').strip()),
                    get_just_code(row.get('rotation').strip()),
                    get_just_code(row.get('nitrogen').strip()),
Ejemplo n.º 3
0
"""

baseheaders = ['UniqueID', 'Rep', 'Tillage', 'Rotation', 'Drainage', 'Nitrogen', 
               'Landscape', 'PlotID', 'ROW', 'COLUMN']
basecolumns = {'A': 'UniqueID', 'B': 'Rep', 'C': 'Tillage', 'D': 'Rotation', 
           'E': 'Drainage', 'F': 'Nitrogen', 'G': 'Landscape','H': 'Plot ID',
           'I': 'ROW', 'J': 'COLUMN'}

letters = ['K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
           'AA','AB','AC','AD','AE','AF','AG','AH','AI','AJ','AK','AL']

DONE = ['orr',]

for entry in meta_feed.entry:
    data = entry.to_dict()
    sitekey = data.get('uniqueid').lower()
    if sitekey not in DONE:
        print 'skip', sitekey
        continue
    # This is the folder where synced data is stored
    colfolder = data.get('colfolder')
    collect = docs_client.get_resource_by_id(colfolder)
    leadpi = data.get('leadpi')
    
    # Lets go find the Plot Identifiers Table
    keyspread = data.get('keyspread')
    # loop over rows
    plots = []
    feed = spr_client.get_list_feed(keyspread, 'od6')
    for feed_entry in feed.entry:
        cols = feed_entry.to_dict()
Ejemplo n.º 4
0
           ['AGR36', '[36] Soybean grain biomass total nitrogen at R8', 'kg ha-1'],
           ['AGR37', '[37] Cover crop (rye) and weedy biomass in late fall', 'kg ha-1'],
           ['AGR38', '[38] Weedy biomass (only) in late fall', 'kg ha-1']
           ]

for entry in feed:
    spreadkey = entry.id.text.split("/")[-1][14:]
    feed2 = spr_client.GetWorksheets( spreadkey )
    for entry2 in feed2.entry:
        worksheet = entry2.id.text.split("/")[-1]
        print 'Processing %s WRK: %s Title: %s' % (entry.title.text, 
                                                   worksheet, entry2.title.text),
        feed3 = spr_client.get_list_feed(spreadkey, worksheet)
        row = feed3.entry[0]
        data = row.to_dict()
        if data.get('agr6') is None and data.get('agr7') is None:
            print ' ... not found!'
            continue

        plusone = int(entry2.col_count.text) + 4
        entry2.col_count.text = str(plusone)
        spr_client.update(entry2)
        
        # Add a column?
        for i in range(len(newcols)):
            cell = spr_client.get_cell(spreadkey, worksheet,1, plusone-i)
            cell.cell.input_value = newcols[i][0]
            spr_client.update(cell)
    
            cell = spr_client.get_cell(spreadkey, worksheet,2, plusone-i)
            cell.cell.input_value = newcols[i][1]
Ejemplo n.º 5
0
config = util.get_config()

spr_client = util.get_spreadsheet_client(config)
drive = util.get_driveclient(config)

meta_feed = spr_client.get_list_feed(config["cscap"]["metamaster"], "od6")
sdc_feed = spr_client.get_list_feed(config["cscap"]["sdckey"], "od6")
treat_feed = spr_client.get_list_feed(config["cscap"]["treatkey"], "od6")

sdc_data, sdc_names = util.build_sdc(sdc_feed)

NOTDONE = ["VICMS"]

for entry in meta_feed.entry:
    data = entry.to_dict()
    sitekey = data.get("uniqueid").lower()
    if sitekey.upper() not in NOTDONE:
        print("skip %s" % (sitekey, ))
        continue
    soil15 = "SOIL15" in sdc_data["2013"][sitekey]
    soil16 = "SOIL16" in sdc_data["2013"][sitekey]
    soil23 = "SOIL23" in sdc_data["2013"][sitekey]
    if not soil15 and not soil16 and not soil23:
        print(f"Skipping {sitekey} as they have no entries for SOIL15,16,23")
        continue
    # This is the folder where synced data is stored
    colfolder = data.get("colfolder")
    leadpi = data.get("leadpi")

    # Lets go find the Plot Identifiers Table
    keyspread = data.get("keyspread")
Ejemplo n.º 6
0
    "Drainage",
    "Nitrogen",
    "Landscape",
    "My ID",
]


def get_just_code(text):
    if text == "":
        return ""
    return text.split()[0]


for entry in meta_feed.entry:
    data = entry.to_dict()
    sitekey = data.get("uniqueid").lower()
    if sitekey is None:
        continue
    print(sitekey)
    leadpi = data.get("leadpi")
    pi_spreadsheet = spr_client.get_list_feed(data.get("keyspread"), "od6")
    current_entries = []
    for le in pi_spreadsheet.entry:
        row = le.to_dict()
        for key in row:
            if row[key] is None:
                row[key] = ""
        key = "%s||%s||%s||%s||%s||%s" % (
            get_just_code(row.get("tillage").strip()),
            get_just_code(row.get("rotation").strip()),
            get_just_code(row.get("nitrogen").strip()),
Ejemplo n.º 7
0
import ConfigParser
import sys
import util

config = ConfigParser.ConfigParser()
config.read('mytokens.cfg')

# Get me a client, stat
spr_client = util.get_spreadsheet_client(config)
docs_client = util.get_docs_client(config)

query = gdata.docs.client.DocsQuery(show_collections='true', title='Agronomic Data')
feed = docs_client.GetAllResources(query=query)

for entry in feed:
    feed2 = spr_client.GetWorksheets(entry.id.text.split("/")[-1][14:])
    for entry2 in feed2.entry:
        worksheet = entry2.id.text.split("/")[-1]
        print 'Processing %s WRK: %s Title: %s' % (entry.title.text, 
                                                   worksheet, entry2.title.text),
        feed3 = spr_client.get_list_feed(entry.id.text.split("/")[-1][14:], worksheet)
        row = feed3.entry[0]
        data = row.to_dict()
        if data.get('agr7', None) is not None:
            row.set_value('agr7', '[7] Cover crop (rye) biomass at termination (spring) (no significant weeds)')
            spr_client.update(row)
            print ' ... updated'
        else:
            print ' ... not found!'
        
Ejemplo n.º 8
0
"""

headers = [
    "UniqueID",
    "Rep",
    "Tillage",
    "Rotation",
    "Drainage",
    "Nitrogen",
    "Landscape",
    "My ID",
]

for entry in meta_feed.entry:
    data = entry.to_dict()
    sitekey = data.get("uniqueid").lower()
    if data.get("keyspread") is not None:
        continue
    leadpi = data.get("leadpi")
    colfolder = data.get("colfolder")
    collect = docs_client.get_resource_by_id(colfolder)

    # Figure out how many
    rows = []
    trt = treatments[sitekey]
    for k in ["TIL", "ROT", "DWM", "NIT", "LND"]:
        if len(trt[k]) > 1:
            trt[k].remove(None)

    for till in trt["TIL"]:
        for rot in trt["ROT"]:
Ejemplo n.º 9
0
treat_feed = spr_client.get_list_feed(config.get('cscap', 'treatkey'), 'od6')
meta_feed = spr_client.get_list_feed(config.get('cscap', 'metamaster'), 'od6')

treatments, treatment_names = util.build_treatments(treat_feed)

"""
Okay, we are cross product TIL x ROT x DWM x NIT
"""

headers = ['UniqueID', 'Rep', 'Tillage', 'Rotation', 'Drainage', 
           'Nitrogen', 'Landscape','My ID']

for entry in meta_feed.entry:
    data = entry.to_dict()
    sitekey = data.get('uniqueid').lower()
    if sitekey is None or sitekey.find('vicms') == -1:
        continue
    leadpi = data.get('leadpi')
    colfolder = data.get('colfolder')
    collect = docs_client.get_resource_by_id(colfolder)
    
    # Figure out how many 
    rows = []
    trt = treatments[sitekey]
    for k in ['TIL','ROT','DWM','NIT','LND']:
        if len(trt[k]) > 1:
            trt[k].remove(None)
            
    for till in trt['TIL']:
        for rot in trt['ROT']:
Ejemplo n.º 10
0
config.read("mytokens.cfg")

spr_client = util.get_spreadsheet_client(config)
drive = util.get_driveclient()

meta_feed = spr_client.get_list_feed(config.get("cscap", "metamaster"), "od6")
sdc_feed = spr_client.get_list_feed(config.get("cscap", "sdckey"), "od6")
treat_feed = spr_client.get_list_feed(config.get("cscap", "treatkey"), "od6")

sdc_data, sdc_names = util.build_sdc(sdc_feed)

DONE = ["VICMS"]

for entry in meta_feed.entry:
    data = entry.to_dict()
    sitekey = data.get("uniqueid").lower()
    if sitekey.upper() not in DONE:
        print "skip", sitekey
        continue
    # This is the folder where synced data is stored
    colfolder = data.get("colfolder")
    leadpi = data.get("leadpi")

    # Lets go find the Plot Identifiers Table
    keyspread = data.get("keyspread")
    # loop over rows
    plots = []
    feed = spr_client.get_list_feed(keyspread, "od6")
    for feed_entry in feed.entry:
        cols = feed_entry.to_dict()
        if cols.get("plotid", "") not in ["", None]: