Repository: weecology/retriever

Issue:
FIA dataset - 3 states are missing: NewMexico, Wyoming and Mississippi 
However, those states have been nationally standardized. I checked the data in order to get in when that has been did:

Where PLOT.DESIGNCD = 1, we have:

| State_id | PLOT.INVYR |
| --- | --- |
| MS | 2006 |
| NM | 1999 |
| WY | 2000 |



Discussion:

Resolving patch:
diff --git a/scripts/fia.py b/scripts/fia.py
--- a/scripts/fia.py
+++ b/scripts/fia.py
@@ -1,6 +1,6 @@
 #retriever
 """Retriever script for Forest Inventory and Analysis
- 
+
 """
 
 import os
@@ -27,35 +27,36 @@ def __init__(self, **kwargs):
         self.addendum = """This dataset requires downloading many large files - please be patient."""
 
     def download(self, engine=None, debug=False):
-        Script.download(self, engine, debug)        
+        Script.download(self, engine, debug)
         engine = self.engine
-        
+
         # download and create species table
         table = Table('species')
         self.engine.auto_create_table(table, url=self.urls['species'])
         self.engine.insert_data_from_url(self.urls['species'])
-        
+
         # State abbreviations with the year annual inventory began for that state
-        stateslist = [('AL', 2001), ('AK', 2004), ('AZ', 2001), ('AR', 2000), 
-                      ('CA', 2001), ('CO', 2002), ('CT', 2003), ('DE', 2004), 
-                      ('FL', 2003), ('GA', 1998), ('ID', 2004), ('IL', 2001), 
-                      ('IN', 1999), ('IA', 1999), ('KS', 2001), ('KY', 1999), 
-                      ('LA', 2001), ('ME', 1999), ('MD', 2004), ('MA', 2003), 
-                      ('MI', 2000), ('MN', 1999), ('MO', 1999), ('MT', 2003), 
-                      ('NE', 2001), ('NV', 2004), ('NH', 2002), ('NJ', 2004), 
-                      ('NY', 2002), ('NC', 2003), ('ND', 2001), ('OH', 2001), 
-                      ('OK', 2008), ('OR', 2001), ('PA', 2000), ('RI', 2003), 
-                      ('SC', 1999), ('SD', 2001), ('TN', 2000), ('TX', 2001), 
-                      ('UT', 2000), ('VT', 2003), ('VA', 1998), ('WA', 2002), 
-                      ('WV', 2004), ('WI', 2000), ('PR', 2001)]
-        
+        stateslist = [('AL', 2001), ('AK', 2004), ('AZ', 2001), ('AR', 2000),
+                      ('CA', 2001), ('CO', 2002), ('CT', 2003), ('DE', 2004),
+                      ('FL', 2003), ('GA', 1998), ('ID', 2004), ('IL', 2001),
+                      ('IN', 1999), ('IA', 1999), ('KS', 2001), ('KY', 1999),
+                      ('LA', 2001), ('ME', 1999), ('MD', 2004), ('MA', 2003),
+                      ('MI', 2000), ('MN', 1999), ('MO', 1999), ('MS', 2006),
+                      ('MT', 2003), ('NE', 2001), ('NV', 2004), ('NH', 2002),
+                      ('NJ', 2004), ('NM', 1999), ('NY', 2002), ('NC', 2003),
+                      ('ND', 2001), ('OH', 2001), ('OK', 2008), ('OR', 2001),
+                      ('PA', 2000), ('RI', 2003), ('SC', 1999), ('SD', 2001),
+                      ('TN', 2000), ('TX', 2001), ('UT', 2000), ('VT', 2003),
+                      ('VA', 1998), ('WA', 2002), ('WV', 2004), ('WI', 2000),
+                      ('WY', 2000), ('PR', 2001)]
+
         tablelist = ["SURVEY", "PLOT", "COND", "SUBPLOT", "SUBP_COND", "TREE", "SEEDLING"]
-        
+
         for table in tablelist:
             for state, year in stateslist:
-                engine.download_files_from_archive(self.urls["main"] + state + "_" + table + ".ZIP", 
+                engine.download_files_from_archive(self.urls["main"] + state + "_" + table + ".ZIP",
                                                    [state + "_" + table + ".CSV"])
-        
+
         for table in tablelist:
             print "Scanning data for table %s..." % table
             prep_file_name = "%s.csv" % table
@@ -64,9 +65,9 @@ def download(self, engine=None, debug=False):
             col_names = this_file.readline()
             prep_file.write(col_names)
             column_names = [col.strip('"') for col in col_names.split(',')]
-            year_column = column_names.index("INVYR")            
+            year_column = column_names.index("INVYR")
             this_file.close()
-            
+
             for state, year in stateslist:
                 this_file = open(engine.format_filename(state + "_" + table + ".CSV"), "rb")
                 this_file.readline()
@@ -79,13 +80,13 @@ def download(self, engine=None, debug=False):
             engine.auto_create_table(Table(table), filename=prep_file_name)
 
             engine.insert_data_from_file(engine.format_filename(prep_file_name))
-            
+
             try:
                 os.remove(engine.format_filename(prep_file_name))
             except:
                 pass
-        
+
         return engine
-        
-        
+
+
 SCRIPT = main()


Test patch: