sorry missed; with current code IT is reading / prints ONLY first lines for each 96 set of files are displayed. DOES NOT go the Next row or the Next Set of Files.
PL .... PL ... give me the solution. Thanks Nitin ********************************* PR1 0.000000 0.153436 0.016740 1.362566 -0.031154 1.132133 0.266704 PR3 -0.047642 0.059674 0.271700 0.047802 -0.085366 0.016262 PR1 0.005000 0.137681 0.063328 1.396118 0.015738 1.374378 0.313304 PR3 -0.008209 0.059674 0.339661 -0.046058 0.087159 0.008836 PR1 0.010000 0.200700 0.008988 1.431611 0.007935 1.478203 0.285076 PR3 -0.047827 0.075154 0.201622 -0.022574 0.087495 0.027239 PR1 0.015000 0.145697 0.016801 1.431463 -0.023277 1.651546 0.333441 PR3 -0.023871 0.082955 0.547534 0.040449 0.053501 -0.059713 PR1 0.000000 -3.404975 -0.965380 26.688482 -0.538069 7.530815 -0.076355 PR3 1.736750 0.261636 7.920164 0.579122 2.579521 -0.468668 PR1 0.005000 -3.381482 -1.012078 26.964482 -0.546172 7.566007 -0.104835 PR3 1.784014 0.315952 7.989384 0.634342 2.439866 -0.584216 PR1 0.010000 -3.358453 -1.004423 26.654238 -0.530866 7.150382 -0.085785 PR3 1.807878 0.362540 7.748612 0.595252 2.581121 -0.335703 PR1 0.015000 -3.327500 -0.880397 26.480582 -0.593364 7.323216 -0.056011 PR3 1.736750 0.347047 7.886282 0.429967 2.304293 -0.275297 PR1 0.000000 -0.004793 0.030768 0.356952 -0.036841 0.332747 -0.087458 PR3 -1.433546 -0.237249 7.929407 -0.446087 2.454336 0.326635 PR1 0.005000 -0.020455 -0.008018 0.461187 -0.036616 0.367250 -0.077974 PR3 -1.401758 -0.229472 7.722859 -0.548049 2.662068 0.290733 PR1 0.010000 -0.067348 -0.046731 0.218824 -0.036541 0.263715 -0.087470 PR3 -1.457039 -0.237212 7.618937 -0.485251 2.350271 0.318161 PR1 0.015000 -0.043669 -0.039003 0.322279 -0.052372 0.506002 -0.096786 PR3 -1.449300 -0.229472 7.687630 -0.563655 2.593573 0.233980 PR1 0.000000 1.641553 0.391073 13.009227 0.214600 1.953616 0.015595 PR3 0.146105 0.032141 0.840999 0.006657 0.178160 -0.130106 PR1 0.005000 1.681172 0.391073 13.008975 0.222178 2.196009 0.025139 PR3 0.114503 0.024401 0.946306 0.124525 -0.235777 0.057199 PR1 0.010000 1.649384 0.391061 13.042360 0.238084 2.334502 0.005910 PR3 0.082993 0.032141 0.876697 0.156186 0.283311 -0.066508 PR1 0.015000 1.673248 0.429835 12.801305 0.214450 2.231176 0.091931 PR3 0.106672 0.016600 1.049760 0.054149 -0.858067 0.058464 PR1 0.000000 -0.130893 -0.171140 0.332583 -0.030145 1.476301 -0.362464 PR3 0.051427 -0.025635 0.600788 0.118771 0.509802 -0.041242 PR1 0.005000 -0.115045 -0.171091 0.470262 -0.014539 1.685376 -0.458278 PR3 0.020196 -0.048916 0.290571 0.001202 0.129074 -0.048434 PR1 0.010000 -0.099198 -0.194348 0.297432 0.001141 1.442160 -0.391747 PR3 -0.027253 -0.025610 0.532962 -0.006900 -0.147851 -0.029492 PR1 0.015000 -0.130522 -0.186620 0.712175 0.008944 1.339193 -0.401560 PR3 0.059166 -0.010105 0.188483 0.024012 0.302548 -0.001217 On Thu, Aug 26, 2010 at 1:10 AM, nitin chandra <nitinchand...@gmail.com> wrote: > Hi all, > > I have been getting support on this from the list, but unfortunately > now it has become URGENT that i get some solution to this problem i > need to resolve. > > What i have done is create FileA.CSV whose structure is as follows :- > (no blank spaces, this is just for representation) > /home/nitin/path/To/PRl1/File1.csv , /home/nitin/path/To/PR3/File1.csv > , /home/nitin/path/To/PR2/File1.csv > /home/nitin/path/To/PRl1/File2.csv , /home/nitin/path/To/PR3/File2.csv > , /home/nitin/path/To/PR2/File2.csv > /home/nitin/path/To/PRl1/File3.csv , /home/nitin/path/To/PR3/File3.csv > , /home/nitin/path/To/PR2/File3.csv > /home/nitin/path/To/PRl1/File4.csv , /home/nitin/path/To/PR3/File4.csv > , /home/nitin/path/To/PR2/File4.csv > ... > ... > (96) rows > > The first column is INPUT Protocol-1 File1 > Second Column is INPUT Protocol-3 File1 > Third Column is OUTPUT Protocol-2 File1 > > Each File (eg. PR1/File1 , PR3/File1 ) have approx. 600 rows of 39 > column, numeric data. These data files end in a blank new line / blank > line. > > Through the following code I am trying to read the TWO input files, > extract columns, Add , Divide (take mean of the values) and write to > THEIR respective OUTPUT files. > > My script reads the first file and displays all the rows (print) from > PR1/File1 and then program terminates. IT does not read the Second > file (PR3/File1) and therefore i am unable to write the result out to > the OUTPUT file (PR2/File1). > > Earlier I was able to create ONE file ... like the loop would run ONCE > and would not do the same process to the NEXT set of files (PR1/File2 > , PR3/File2 , PR2/File2) and do the same.... till it has done > processing all the 96 set of files. > > here is the code > PL ... PL .... I REALLY need this solution. > > ***************************** > import sys, os, fileinput > > > FileA = raw_input('Enter CSV file with List of Files :') > try: > fp1 = open(FileA,'r') > #print fp1 > except IOError: > sys.exit('Could not open File : %s' % FileA) > > for rows in fp1: > #print rows > row11 = rows.split(",") > #print row1 > row1 = row11[0] > row2 = row11[1] > row3 = row11[2] > #print row1 > #print row2 > #print row3 > try: > fp2 = open(row1,'r') > #print fp2 > except IOError: > sys.exit('Could not open File %s.' % fp2) > try: > fp3 = open(row2,'r') > #print fp3 > except IOError: > sys.exit('Could not open File %s.' % fp3) > try: > fp4 = open(row3,'w') > #print fp4 > except IOError: > sys.exit('Could not open File %s to write.' % fp4) > > row21 = fp2.readline().split(",") > row31 = fp3.readline().split(",") > #print row21 > row22 = row21[0] > row23 = row21[1] > row24 = row21[2] > row25 = row21[3] > row26 = row21[21] > row27 = row21[22] > row28 = row21[23] > > row32 = row31[1] > row33 = row31[2] > row34 = row31[3] > row35 = row31[21] > row36 = row31[22] > row37 = row31[23] > print "PR1", row22, row23, row24, row25, row26, row27, row28, > "PR3", row32, row33, row34, row35, row36, row37 > > ## Doing the Addition is also not the problem. I am not able to put this > ## whole process in a loop. > ## do the calculation and write to file. > ## and do the same thing with the next set of files. Till 96 sets > _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor