Feb-08-2020, 07:48 AM
Hi, this is the code that i was able to realize by following steps seen on one of the forums :
![[Image: tk8o.jpg]](https://zupimages.net/up/20/06/tk8o.jpg)
what is missing in saving the contents of the tabewidget in the text file is the header of the tabewidget
like indicated as follow :
![[Image: 3616.jpg]](https://zupimages.net/up/20/06/3616.jpg)
my wish is how to add the header of the tablewidgte at the top of the text file
def create_file_from_tableWidget(self): path,_ = QFileDialog.getSaveFileName( self, 'Save File', '', 'CSV(*.txt)') if path: with open(path, 'w',encoding="utf-8") as stream: writer = csv.writer(stream, delimiter='\t') for row in range(self.tableWidget_search.rowCount()): rowdata = [] for column in range(self.tableWidget_search.columnCount()): item = self.tableWidget_search.item(row, column) if item is not None: rowdata.append( item.text()) else: rowdata.append('') writer.writerow(rowdata)the result is like at on the following picture :
![[Image: tk8o.jpg]](https://zupimages.net/up/20/06/tk8o.jpg)
what is missing in saving the contents of the tabewidget in the text file is the header of the tabewidget
like indicated as follow :
![[Image: 3616.jpg]](https://zupimages.net/up/20/06/3616.jpg)
my wish is how to add the header of the tablewidgte at the top of the text file