How to write Pandas Dataframe as a table to PDF using fpdf python

757 Views Asked by At

I want to create a pdf that contains customized tables. For that I have converted a text file into dataframe using pandas as this text file contains some string and numerical data ( abc = 1234 format).

 with open(input2_filename,"rt") as ip1:
        for line in ip1:
            for i in patterns:
                match1 = re.match(i,line)
                if match1 != None:
                    er4.append(match1.groups())


df4 = pd.DataFrame(er4, columns =['Attribute', 'Values'])

Issues:

  • How to convert dataframe into customized table that is presentable?
  • How to add this table directly in the PDF without saving as an image?

Do anyone have solution for this? If anyone knows how to do it in a better way, that would be appreciated.

I have tried tabulate module for converting dataframe into table, but I was unable to add it directly to the pdf. I also tried to save this table as an image and then adding it to the pdf, but it also doesn't work for me.

0

There are 0 best solutions below