wget.download(url, filename)
print("Download complete!")
else:
print("File exists, skipping download.")
// Print 10 random lines
with open(filename, "r") as datafile:
lines = datafile.readlines()
After Change
// and extract it in a ``data`` directory under the current directory.
//
filename = "data/iris.data"
// Print 10 random lines
try:
datafile = open(filename, "r")
except IOError:
print("Cannot open data file: {}. Have you downloaded it yet?".format(filename))
exit()
lines = datafile.readlines()
// Last line in file is empty, we"ll deal with this later
lines = lines[:-1]
random.shuffle(lines)
for line in lines[:10]:
print(line.strip())
datafile.close()
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Next, we"ll create our dataset, which is a list of lists containing each
// row of the data file (shape=(150,5)).