Skip to content

Instantly share code, notes, and snippets.

@thomas-maschler
Created November 3, 2014 20:50
Show Gist options
  • Save thomas-maschler/8828fd69fa8f3cb390aa to your computer and use it in GitHub Desktop.
Save thomas-maschler/8828fd69fa8f3cb390aa to your computer and use it in GitHub Desktop.
Download Nasa Global 24h fire alerts and process file line by line
import os
import urllib
import csv
url = 'https://firms.modaps.eosdis.nasa.gov/active_fire/text/Global_24h.csv'
file_path = 'path_where_you_what_to_save_file'
urllib.urlretrieve(url, file_path)
with open(file_path, 'rb') as csvfile:
fires = csv.reader(csvfile, delimiter=',', quotechar='"')
i = 0
for row in fires:
#you might want to skip the first line
if i = 0:
i += 1
elif:
#you can access every attribute in a row by index
lat = row[0]
lon = row[1]
...
update_cartodb(lat,lon,...)
csvfile.close()
os.remove(file_path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment