1

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)
yasmikash
  • 157
  • 2
  • 14
saeed
  • 11
  • 2
  • Instead of doing this `.to_dict()` method, could you use this [solution instead](https://stackoverflow.com/a/31476710/9221467)? – SRT HellKitty Apr 29 '19 at 18:58

0 Answers0