import pickle
import requests
# getting iris dataset from a web address
resp = requests.get("https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data")
# saving the web data into a text file
with open("iris.txt", "w") as f:
f.write(resp.text)
# reading the created text file containing the web data
with open("iris.txt", "r") as f:
dataset = f.read()
# splitting the web data in text file
listof = dataset.split("\n")
# converting list into list of lists
lol = [[item] for item in listof]
# pickling the data
pickleed = open("irislists.pkl", "wb")
pickle.dump(file=pickleed, obj=lol)
pickleed.close()
# unpickling the data
unpickleed = open("irislists.pkl", "rb")
pythonobj = pickle.load(file=unpickleed)
print(pythonobj)
unpickleed.close()
Comments
Post a Comment
Write something to CodeWithAbdur!