Skip to content

Commit

Permalink
Merge pull request #470 from ethanwhite/fix-bbs-routes
Browse files Browse the repository at this point in the history
Update BBS scripts now that longitudes have proper signs
  • Loading branch information
henrykironde committed Apr 20, 2016
2 parents b473b16 + c941a13 commit 33ba9ee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 38 deletions.
21 changes: 3 additions & 18 deletions scripts/bbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 3 additions & 20 deletions scripts/bbs50stop.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")):
Expand Down

0 comments on commit 33ba9ee

Please sign in to comment.