hi everyone i have made a program which extracts information from an email account, it extracts the date, the sender, number of copies written in the body, and it extracts the pdf file from the email and puts it into a directory, it also counts the number of pages in each pdf.

i have strings setup so that in the python out put its outputs the date, teacher, copies, and pages. since there are more than one email, the uotput returns more than one oupt put, for example if there are two emails it will output two dates, two teachers, two number of copies, and two page number.

how do i inpt this information in a table using xlwt. so that each i can create a spreadsheet which has all this information in it.

I think you are on the right track. Just open your xls book before you start reading your email ( i.e before line 18. and add your headers ( line 119 to line 123 ). Initialize a counter before line 74 to 1 ( i.e. you have written a line to your worksheet. ) and use it to write data to new rows by updating the counter. I think you can put the page reading loop ( line 102 to 110 ) inside the for loop that begins on line 74. This is what I riggeed up ( plz donot copy this code blindly as it may contain errors ) :

so basically i did what was suggested and it works great when its not in the for loop but it only inserts the first output of the python program. but when i put in into the for loop so that inputs all the output into the spreadsheet it gives me an error.
plus i put the page counter loop into the for loop how can i edit the page counter loop so that it doesnt repeat itself twice.

I think you are on the right track. Just open your xls book before you start reading your email ( i.e before line 18. and add your headers ( line 119 to line 123 ). Initialize a counter before line 74 to 1 ( i.e. you have written a line to your worksheet. ) and use it to write data to new rows by updating the counter. I think you can put the page reading loop ( line 102 to 110 ) inside the for loop that begins on line 74. This is what I riggeed up ( plz donot copy this code blindly as it may contain errors ) :

Oh sorry... That was my mistake. You need to define row = 1 before the first for loop, i.e before line 28. Also I did notice that an improperly formatted pdf file or just any file with an extension as .pdf will give raise to an error on line number 106. Probably try-expect loop will help you deal with the error.

Oh sorry... That was my mistake. You need to define row = 1 before the first for loop, i.e before line 28. Also I did notice that an improperly formatted pdf file or just any file with an extension as .pdf will give raise to an error on line number 106. Probably try-expect loop will help you deal with the error.

how can i get rid of the loop in this pdf page counter, since i already have it wrapped in another loop theres no reason to have it in a loop again becuase it just repeats its self twice, heres the code and how can i remove the loop within it, and have the loop before it do the same thing to it?