0
votes

I have a function that I want to run for each element in the list models. These elements correlate to a header in and excel document with models up to model10.

What I'd like it to do now is read what models are needed, then iterate the function for each of the models dictated in models. So it reads the models as the header, then creates a PDF document with each of the files from the excel under the header mentioned.

My dataframe looks like this:

   model1      model2    model3     
0  File1.pdf   File3.pdf File2.pdf
1  File2.pdf   nan.pdf   File2.pdf
2  File3.pdf   nan.pdf   File2.pdf
models = ["model1","model2","model3"]
def merge_pdf(models):
        merger = PdfFileMerger()
        for col_name in models:
            for index, row in df.iterrows():
                merger.append(row[col_name])
        merger.write(f"Test({col_name}).pdf")
        merger.close()
merge_pdf(models)

My expected output: 3 separate PDF files that is created following rows under the header, so one PDF pack that contains File1, File2 & File3, another with just File3 and so on.

Error I get: "AttributeError: 'float' object has no attribute 'seek'"

What error did you encounter with the above?Chris Broz
AttributeError: 'float' object has no attribute 'seek'Chaotic.Python