Get your original paper written from scratch starting at just $10 per page with a plagiarism report and free revisions included!
Question: Add the functionality of adding a dataset to another dataset. Essentially, using this functionality, one would able to add all data of one dataset to another dataset and use it. It would have one argument of type class dataset and no return value as it adds the parameter dataset’s value to self’s dataset.
For this question, the bottom line is that the below cell should work.
# Do not change this cell
print(len(txt_data))
csv_data.append_dataset(txt_data)
print(len(csv_data))
You have to decide where this function would go from the above three classes and implement it.
—– Other Classes —–
#Implement dataset class in this cell
class dataset:
def __init__(self):
self.list = []
def __getitem__(self, index):
if (len(self.list) > index):
return (self.list[index])
else:
return None
def __len__ (self):
return len(self.list)
def append_data(self, item):
return self.list.append(item)
pass
# Implement txt_dataset class in this cell
class txt_dataset(dataset):
def __init__(self,filename,splitter,encoding):
super().__init__()
self.append_file(filename,splitter,encoding)
def append_file(self,filename,splitter,encoding):
file=open(filename,encoding=’utf8′)
line=file.readline()
while line:
self.append_data(tuple(line.split(splitter)))
line=file.readline()
pass
# Implement csv_dataset in this cell
import csv
class csv_dataset(dataset):
def __init__(self,filename,splitter,encoding):
super().__init__()
file=open(filename,encoding=’utf8′)
reader = csv.reader(filename, delimiter=”;”)
for line in file:
data_value=line.split(splitter)
super().append_data(tuple(data_value))
def append_file(self,filename,splitter,encoding):
reader = csv.reader(filename, delimiter=”;”)
file = open(filename, encoding=encoding)
for line in file:
data_value = line.split(splitter)
super().append_data(tuple(data_value))
The aim of our service is to provide you with top-class essay help when you ask us to write my paper; we do not collect or share any of your personal data. We use the email you provide us to send you drafts, final papers, and the occasional promotion and discount code, but that’s it!
Order Now