In [ ]:
from IPython.display import HTML
HTML('<iframe width="560" height="315" src="https://www.youtube.com/embed/zV949buXdSg?autoplay=1&loop=1" frameborder="0" allowfullscreen></iframe>')
In [ ]:
import pandas as pd
pd.read_table("data/1stn.pdb")
In [ ]:
f = open("test-file.txt")
print(f.readlines())
f.close()
In [ ]:
f = open("test-file.txt")
for line in f.readlines():
print(line)
f.close()
In [ ]:
f = open("test-file.txt")
for line in f.readlines():
print(line,end="")
f.close()
In [ ]:
f = open("test-file.txt")
for line in f.readlines():
print(line.split())
f.close()
In [ ]:
f = open("test-file.txt")
for line in f.readlines():
print(line.split("1"))
f.close()
In [ ]:
f = open("test-file.txt")
lines = f.readlines()
f.close()
line_of_interest = lines[-1]
value = line_of_interest.split()[0]
print(value)
In [ ]:
print(value*5)
value
is a string of "1.5". You can't do math on it yet.
In [ ]:
value_as_float = float(value)
print(value_as_float*5)
In [ ]:
list("1.5")
In [ ]:
f = open(SOME_FILE_NAME,'w')
will wipe out file immediately!f = open(SOME_FILE_NAME,'a')
f.write(SOME_STRING)
f.writelines([STRING1,STRING2,...])
f.close()
In [ ]:
def file_printer(file_name):
f = open(file_name)
for line in f.readlines():
print(line,end="")
f.close()
In [ ]:
a_list = ["a","b","c"]
f = open("another-file.txt","w")
for a in a_list:
f.write(a)
f.close()
file_printer("another-file.txt")
In [ ]:
a_list = ["a","b","c"]
f = open("another-file.txt","w")
for a in a_list:
f.write(a)
f.write("\n")
f.close()
file_printer("another-file.txt")
In [ ]:
a_list = ["a","b","ccat"]
f = open("another-file.txt","w")
for a in a_list:
f.write("A test {{}} {}\n".format(a))
f.close()
file_printer("another-file.txt")
In [ ]:
print("The value is: {:}".format(10.35151))
print("The value is: {:.2f}".format(10.35151))
print("The value is: {:20.2f}".format(10.35151))
In [ ]:
print("The value is: {:}".format(10))
print("The value is: {:20d}".format(10))
In [ ]:
f = open(SOME_FILE_NAME,'w')
will wipe out file immediately!f = open(SOME_FILE_NAME,'a')
f.write(SOME_STRING)
f.writeline([STRING1,STRING2,...])
f.close()