Revision 5737
Added by Aaron Marcuse-Kubitza about 12 years ago
tnrs_db | ||
---|---|---|
10 | 10 |
sys.path.append(os.path.dirname(__file__)+"/../lib") |
11 | 11 |
|
12 | 12 |
import csvs |
13 |
import dates |
|
13 | 14 |
import opts |
14 | 15 |
import profiling |
15 | 16 |
import sql |
... | ... | |
26 | 27 |
|
27 | 28 |
tnrs_input = sql_gen.Table('tnrs_input_name') |
28 | 29 |
tnrs_data = sql_gen.Table('tnrs') |
30 |
time_col_name = 'Time_submitted' |
|
29 | 31 |
|
30 | 32 |
def main(): |
31 | 33 |
# Input |
... | ... | |
68 | 70 |
|
69 | 71 |
# Run TNRS |
70 | 72 |
log('Making TNRS request') |
73 |
now_str = str(dates.now()) |
|
71 | 74 |
tnrs_profiler.start() |
72 | 75 |
try: |
73 | 76 |
try: stream = tnrs.repeated_tnrs_request(names) |
... | ... | |
77 | 80 |
except tnrs.InvalidResponse: pass # skip set in case it caused error |
78 | 81 |
else: |
79 | 82 |
log('Storing TNRS response data') |
80 |
sql_io.append_csv(db, tnrs_data, *csvs.reader_and_header(stream)) |
|
83 |
reader, header = csvs.reader_and_header(stream) |
|
84 |
header.insert(0, time_col_name) |
|
85 |
reader = csvs.ColInsertFilter(reader, lambda row, row_num: now_str) |
|
86 |
sql_io.append_csv(db, tnrs_data, reader, header) |
|
81 | 87 |
|
82 | 88 |
main() |
Also available in: Unified diff
inputs/.TNRS/tnrs/: Added Time_submitted column at beginning and populate it in tnrs_db with the time the batch TNRS request was submitted