I want to upload a dataset into table widget for that first of all I import the data set by pandas.read_csv
library and then pass this to a dict by to_dict()
and append this dictionary into list to show in table widget. Now in table widget it show 16000 record correct but after 16000 record it show only string record. One thing more that I am using def next() for next iteration to upload data into table. Following is the code:
def upload(self):
self.tableWidget.clear()
path = QFileDialog.getOpenFileName(self, "Open File", os.getenv('Home'),'*.csv')
with open(path) as csvfile:
reader = pd.read_csv(csvfile,header=None)
reader1=reader.to_dict(orient='reader1')
for line in reader1:
self.list_name.append(line)
self.tableWidget.setRowCount(len(self.list_name))
self.tableWidget.setColumnCount(len(self.list_name[0]))
for i,row in enumerate(self.list_name):
if i==15000:
break
else:
for j, col in enumerate(row):
#self.tableWidget.scrollToBottom()
#print(i)
item = QTableWidgetItem(row[col])
self.tableWidget.setItem(i, j, item)
def next(self):
self.tableWidget.clear()
self.start+=15000
self.end=self.start+15000
for i,row in enumerate(self.list_name):
if i not in range(self.start,self.end):
continue
else:
for j, col in enumerate(row):
item = QTableWidgetItem(row[col])
self.tableWidget.setItem(i, j, item)