0

This is my Code for write data in csv file.I want to update row of particular index.when I use W+ It is update All Containt of File I want to update particular row wise .

if(index==list.index(total_Rsq)and total_Rsq>MinList)  :   


   s1=list.index(total_Rsq)
   with open("D:/Krutsi_RandD/Python/NNFiles/summary1.csv", 'w+') as csvfile: 
              rows = [[ s1,NN.inputLayerSize,'-',NN.hiddenLayerSize,'-',NN.outputLayerSize , Rsquare , Rsquare1 , argument1 , argument2,list[index]]]
              csvwriter = csv.writer(csvfile)  # creating a csv writer object 
              csvwriter.writerows(rows)   # writing the data rows 
              dummy_var1=total_Rsq

else:
   with open("D:/Krutsi_RandD/Python/NNFiles/summary1.csv", 'a') as csvfile: 

               rows = [[ s1,NN.inputLayerSize,'-',NN.hiddenLayerSize,'-',NN.outputLayerSize , Rsquare , Rsquare1 , argument1 , argument2,list[index]]]
               csvwriter = csv.writer(csvfile)  # creating a csv writer object 
               csvwriter.writerows(rows)   # writing the data rows 
               dummy_var1=total_Rsq
Krutika Parekh
  • 51
  • 1
  • 1
  • 5
  • 1
    Please reformat the code properly! – Nordle Mar 12 '19 at 06:52
  • Didn't get you properly but this might solve your issue [Adam Smith's Answer](https://stackoverflow.com/questions/28416678/python-replacing-value-of-a-row-in-a-csv-file) – Anish Kumar Mar 12 '19 at 07:02

0 Answers0