csv文件

时间:2016-12-08 14:33:24

标签: python csv pyqt

我在PyQt中有应用程序。在提交时,所有组合框和行编辑以及qplaintextedit和来自qtable小部件的信息都会添加到列表中。该列表将数据粘贴到csv文件中并刷新存在的字段。并且新信息被加载到qtablewidget区域。接下来再次将来自以下所有字段的信息+ qtablewidget信息添加到csv文件中。但是,csv文件中的信息变得混乱。 qtablewidget信息必须包含下面给出的字段信息。但它互换了。有什么建议吗?

enter image description here



if os.path.isfile("Rts.csv") is True:

                    with open('Rts.csv', 'r') as fo:
                
                        reader = csv.reader(fo, delimiter = ',')
                        ncol = len(next(reader))
                        data = list(reader)
                        row_count = len(data)

                
                        if staticVariable.static_count_clicked <= row_count:

                            print staticVariable.static_count_clicked

                            main =  data[staticVariable.static_count_clicked]

                            print main

                            data = []

                            xdata = [str(da), str(compout), str(locout), str(resout), str(geotxt), str(landtxt), str(suggestxt), str(remarkstxt)]

                            data = [main + xdata]

                            print data

                            if os.path.isfile("rts_output.csv") is True:
                            
                                with open('rts_output.csv', 'a') as fp:
                            
                                    a = csv.writer(fp, delimiter = ',' )
                            
                                    awrite = a.writerows(data)   

                                fp.close()


            
                            for var in range(0, ncol):                                                  
                                self.dadis.setItem(0, var, QTableWidgetItem(main[var]))


                            pbvar = staticVariable.static_count_clicked
                            print pbvar

                            self.no_cases.setText(str(pbvar) + " Cases done out of - " + str(row_count))

                            staticVariable.static_count_clicked += 1
                            staticVariable.static_main_clicked += 1


                    fp.close()
&#13;
&#13;
&#13;

0 个答案:

没有答案