Repository: weecology/retriever

Issue:
negative latitudes in bbs
It took me a while to track this down.  I was sure I was going insane at first.

Longitude [was conditionally getting multiplied by -1 in bbs.py](https://github.com/ethanwhite/retriever/blob/fc8c143f95fa690365637fa628bda1fa61d39fc7/scripts/bbs.py#L72), but changes to the data set seem to have caused latitude to get flipped instead.  Now my maps are upside-down  ಠ_ಠ

What's the most sensible fix? Should we just change the index, or should we try to dynamically figure out which column is longitude?



Discussion:
@davharris do you have the sample old file before the new change in the data.
I could look at it and indentify which index changed

Working on this now. Should have a PR shortly.


Resolving patch:
diff --git a/scripts/bbs.py b/scripts/bbs.py
--- a/scripts/bbs.py
+++ b/scripts/bbs.py
@@ -58,25 +58,10 @@ def download(self, engine=None, debug=False):
 
 
             # Routes table
-            if not os.path.isfile(engine.format_filename("routes_new.csv")):
-                engine.download_files_from_archive(self.urls["routes"],
-                                                   ["routes.csv"])
-                read = open(engine.format_filename("routes.csv"), "rb")
-                write = open(engine.format_filename("routes_new.csv"), "wb")
-                print "Cleaning routes data..."
-                write.write(read.readline())
-                for line in read:
-                    values = line.split(',')
-                    v = Decimal(values[5])
-                    if  v > 0:
-                        values[5] = str(v * Decimal("-1"))
-                    write.write(','.join(str(value) for value in values))
-                write.close()
-                read.close()
-
+            engine.download_files_from_archive(self.urls["routes"], ["routes.csv"])
             engine.auto_create_table(Table("routes", cleanup=Cleanup()),
-                                     filename="routes_new.csv")
-            engine.insert_data_from_file(engine.format_filename("routes_new.csv"))
+                                     filename="routes.csv")
+            engine.insert_data_from_file(engine.format_filename("routes.csv"))
 
 
             # Weather table
diff --git a/scripts/bbs50stop.py b/scripts/bbs50stop.py
--- a/scripts/bbs50stop.py
+++ b/scripts/bbs50stop.py
@@ -56,27 +56,10 @@ def download(self, engine=None, debug=False):
             engine.insert_data_from_url(self.urls["species"])
 
             # Routes table
-            if not os.path.isfile(engine.format_filename("routes_new.csv")):
-                engine.download_files_from_archive(self.urls["routes"],
-                                                   ["routes.csv"])
-                read = open(engine.format_filename("routes.csv"), "rb")
-                write = open(engine.format_filename("routes_new.csv"), "wb")
-                print "Cleaning routes data..."
-                write.write(read.readline())
-                for line in read:
-                    values = line.split(',')
-                    v = Decimal(values[5])
-                    if  v > 0:
-                        values[5] = str(v * Decimal("-1"))
-                    write.write(','.join(str(value) for value in values))
-                write.close()
-                read.close()
-
+            engine.download_files_from_archive(self.urls["routes"], ["routes.csv"])
             engine.auto_create_table(Table("routes", cleanup=Cleanup()),
-                                     filename="routes_new.csv")
-
-            engine.insert_data_from_file(engine.format_filename("routes_new.csv"))
-
+                                     filename="routes.csv")
+            engine.insert_data_from_file(engine.format_filename("routes.csv"))
 
             # Weather table
             if not os.path.isfile(engine.format_filename("weather_new.csv")):


Test patch: