# Compatible with both python 2.7 & python 3 # Make sure pandas is installed using: pip install --user pandas; pip3 install --user pandas; from __future__ import print_function import numpy as np import sqlite3 import pandas import requests # Download the SQLite file from the GRBweb webpage r = requests.get("https://icecube.wisc.edu/~grbweb_public/GRBweb2.sqlite") f = open('GRBweb2.sqlite', 'wb').write(r.content) # Load the database with the sqlite3 module db = sqlite3.connect('GRBweb2.sqlite') # Print the names of all the tables table_names = pandas.read_sql_query("SELECT * from sqlite_sequence", db) print("Table names:\n", table_names, "\n\n") # From the list of table names, select the one you wish to load. # For example, we will here load the Swift table. Swift_table = pandas.read_sql_query("SELECT * from Swift", db) Swift_table = Swift_table.sort_values("GRB_name") print("Swift table:\n", Swift_table, "\n\n") # Print the first entry in the Swift table print("First entry in Swift table:") keys = Swift_table.keys() First_entry = Swift_table.values[0] for key, value in zip(keys, First_entry): print("{:>12}: {:<25}".format(key, value)) # Get numpy arrays containing the right ascension, declination, mjd, ... # of the entries in the Summary table Summary_table = pandas.read_sql_query("SELECT * from Summary", db) keys = Summary_table.keys() print("\n\nKeys in the 'Summary' table:", list(keys)) RA = np.array(Summary_table.ra) # right ascension DEC = np.array(Summary_table.decl) # declination MJD = np.array(Summary_table.mjd) # modified julian date print(" RA:", RA) print(" DEC:", DEC) print(" MJD:", MJD)