Revision 5737
Added by Aaron Marcuse-Kubitza about 12 years ago
inputs/.TNRS/tnrs/header.csv | ||
---|---|---|
1 |
Name_number,Name_submitted,Overall_score,Name_matched,Name_matched_rank,Name_score,Name_matched_author,Name_matched_url,Author_matched,Author_score,Family_matched,Family_score,Name_matched_accepted_family,Genus_matched,Genus_score,Specific_epithet_matched,Specific_epithet_score,Infraspecific_rank,Infraspecific_epithet_matched,Infraspecific_epithet_score,Infraspecific_rank_2,Infraspecific_epithet_2_matched,Infraspecific_epithet_2_score,Annotations,Unmatched_terms,Taxonomic_status,Accepted_name,Accepted_name_author,Accepted_name_rank,Accepted_name_url,Accepted_name_species,Accepted_name_family,Selected,Source,Warnings,Accepted_name_lsid |
|
1 |
Time_submitted,Name_number,Name_submitted,Overall_score,Name_matched,Name_matched_rank,Name_score,Name_matched_author,Name_matched_url,Author_matched,Author_score,Family_matched,Family_score,Name_matched_accepted_family,Genus_matched,Genus_score,Specific_epithet_matched,Specific_epithet_score,Infraspecific_rank,Infraspecific_epithet_matched,Infraspecific_epithet_score,Infraspecific_rank_2,Infraspecific_epithet_2_matched,Infraspecific_epithet_2_score,Annotations,Unmatched_terms,Taxonomic_status,Accepted_name,Accepted_name_author,Accepted_name_rank,Accepted_name_url,Accepted_name_species,Accepted_name_family,Selected,Source,Warnings,Accepted_name_lsid |
inputs/.TNRS/schema.sql | ||
---|---|---|
1 | 1 |
CREATE TABLE tnrs |
2 | 2 |
( |
3 |
"Time_submitted" timestamp with time zone, |
|
3 | 4 |
"Name_number" text, |
4 | 5 |
"Name_submitted" text NOT NULL, |
5 | 6 |
"Overall_score" text, |
bin/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