Changes between Version 27 and Version 28 of INTEGRATING fish


Ignore:
Timestamp:
Dec 6, 2010 10:05:47 PM (14 years ago)
Author:
cedric
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • INTEGRATING fish

    v27 v28  
    209209select count(*) from wrbd.fish_fi; --26050 
    210210}}} 
     211 = specimen_tw_08_09 = 
     212{{{ 
     213drop table if exists wrbd.specimen_tw_08_09; 
     214create table wrbd.specimen_tw_08_09( 
     215estuary_name text, 
     216date date, 
     217easting integer, 
     218northing integer, 
     219lat numeric, 
     220long numeric, 
     221net_no text, 
     222net_individual_no text, 
     223net_type text, 
     224length_cm numeric, 
     225lifestage text, 
     226sex text, 
     227anguillicola_count integer, 
     228weight_of_anguillicola_infection_g numeric, 
     229otoliths_taken text, 
     230otolith_box_no text, 
     231stomach_contents text, 
     232comment text); 
     233 
     234copy wrbd.specimen_tw_08_09 from 'C:/base/specimen_tw_08_09.csv' with CSV header delimiter as ';'; 
     235-- a long and painfull process to verify that the names match, the cooridinates of the stations were sometimes different ex: Moy, I had only 39 station  
     236select count (*) from wrbd.specimen_tw_08_09; --98 
     237select * from  wrbd.specimen_tw_08_09 left join wrbd.station_st on (estuary_name)=(st_location); -- OK everything is filled in 98 
     238 
     239drop table if exists wrbd.specimen_tw_08_09_1; 
     240create table wrbd.specimen_tw_08_09_1 as( 
     241select ss.st_id as fi_st_id,extract(year from date) as year, sr.* from  wrbd.specimen_tw_08_09 sr left join wrbd.station_st ss on (estuary_name)=(st_location) 
     242); 
     243drop table wrbd.specimen_tw_08_09; 
     244-- le seul pivot possible est sur l'année 
     245select * from wrbd.specimen_tw_08_09_1 join wrbd.operation_op on (op_st_id,op_year)=(fi_st_id,year) ;-- 98 
     246create table wrbd.specimen_tw_08_09_2 as( 
     247        select o.op_id as fi_ope_id, sr.* from wrbd.specimen_tw_08_09_1 sr join wrbd.operation_op o on (op_st_id,op_year)=(fi_st_id,year) 
     248); 
     249drop table wrbd.specimen_tw_08_09_1; 
     250--wrbd.specimen_tw_08_09_2 now contains operation and stations 
     251 
     252insert into wrbd.fish_fi( 
     253fi_st_id, 
     254fi_op_id, 
     255fi_date, 
     256fi_year, 
     257fi_lifestage, 
     258fi_retained, 
     259fi_length, 
     260fi_sex, 
     261fi_anguillicola_nos, 
     262fi_anguillicolaweight 
     263) 
     264  select  
     265fi_st_id,  
     266fi_ope_id, 
     267date, 
     268year, 
     269lifestage, 
     270case when otoliths_taken is not null then 'yes' 
     271else 'no' end as retained, 
     272length_cm, 
     273sex, 
     274anguillicola_count, 
     275weight_of_anguillicola_infection_g 
     276from wrbd.specimen_tw_08_09_2; 
     277 
     278drop table wrbd.specimen_tw_08_09_2; 
     279 
     280select count(*) from wrbd.fish_fi; --26148 
     281}}}