Skip to content

Instantly share code, notes, and snippets.

View BlogBlocks's full-sized avatar

Jack Northrup BlogBlocks

View GitHub Profile
"""
Learn to download and save a CSV file
open it and read the data
"""
import sys
from itertools import islice
import urllib2
# CO2.csv source
url = 'http://pchart.sourceforge.net/Resources/CO2.csv'
# Open the URL
import pylab
Text = """315.42,
316.31,
316.5,
317.56,
318.13,
318,
316.39,
314.65,
313.68,
# Created for Jupyter Notebook
#learn by experimenting
import matplotlib.pyplot as plt
data=[(215.42,316.31,416.5),(327.56,428.13,338.0),(322.36,448.46,372.7)]
print"A:",([data[0][1]]),\
"\nB:", (data[0][0]),\
"\nC:", (data[0][2]),\
"\nD:", (data[1][1]),\
"\nE:", (data[2]),\
#!/usr/bin/python
"""
Just playing with randint, lists and plots
Created for Jupyter Notebook
Useage:
import ToyPlot
ToyPlot.toyplot()
"""
import matplotlib.pyplot as plt
from random import randint
#Date as year and Decimal
# USAGE: import Date_in_Dec
# Date_in_Dec.Today()
# Returns: 2017.896174863388
import time
def Today():
Date2Day = (float(time.strftime("%j"))-1) / 366 + float(time.strftime("%Y"))
return Date2Day
if __name__=="__main__":
Today()
# Arg test:
# python ArgTest.py eweewe erer tytyytt sssss
import sys
import numpy as np
import sys
script = sys.argv[0]
filename = sys.argv[1]
test0 = sys.argv[2]
test1 = sys.argv[3]
test2 = sys.argv[4]
#!/usr/local/bin/python
"""
Converts a date into a fraction of a year
Usage: Takes two arguments month and day.
python dateTodec.py 2 22
"""
from __future__ import division
import sys
import math
import sys, getopt
#!/usr/local/bin/python
#Author: JackNorthrup
#Usage : python viewNlines.py data/co2.csv 5
import sys
PATH= sys.argv[1]
try:
N = int(sys.argv[2])
except ValueError:
print "path is to be followed by number of lines to read"
sys.exit(1)
"""
Example: IBM Boulder, CO
Address or Place of Interest :IBM Boulder, CO
Returned:
7 -- lat: 40.0893174,
8 -- lng: -105.1981258},
80 -- formatted_address:
81 -- 6300 Diagonal Hwy, Boulder, CO 80301, USA
83 -- establishment
84 -- point_of_interest
"""Creates a name based on a url:
USAGE:
URL_local = "News---Somali-hijackings-after-five-year-lull_icc-ccs.org_.html"
Ntitle(URL_local)
If used as a module:
import Beautihelp
Beautihelp.Ntitle(URL_local)
"""
def Ntitle(URL_local, exten = -5, length= -17, NewExt = ".txt"):
#removes the period