This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some scripts to learn how to use sys.argv | |
ArgTest1.py | |
#!/usr/local/bin/python | |
import sys | |
a = sys.argv[1] | |
print a | |
-- tryit: | |
!python ArgTest1.py 456 721 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Demonstration: | |
How to remove elements one at a time from a list. | |
front to rear, then rear to front | |
""" | |
from time import sleep | |
ID = [750,771,772,1000,1077,1099,1110,1277,1499, 2000, 20050, 20167] | |
count = 0 | |
inc = len(ID) | |
while count < inc: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pylab | |
Text = """315.42, | |
316.31, | |
316.5, | |
317.56, | |
318.13, | |
318, | |
316.39, | |
314.65, | |
313.68, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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]),\ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |