How do I find the file path of images in a folder so I can extract them and put them on a pdf ?
DataAnalyst24
Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Registered Posts: 7 ✭✭✭
I have the flow below where I want to use the images stored in the Photos folder?
In the folder, there are two images, how can I get those images and add them into the script below that allows me to create pdf files. This part of the script is where the error is coming
pdf.image('/project/XX1111/ABC12DDD/apple.jpeg')
import fpdf from fpdf import FPDF # Create instance of FPDF class pdf = FPDF() # Add a page pdf.add_page() # Set font pdf.set_font("Arial", size = 15) # Add a cell pdf.cell(200, 10, txt = "Hello World", ln = True, align = 'C') # Save the pdf with name .pdf pdf.output("report.pdf") #Add-Image folder = dataiku.Folder("Photos") Photos_info = Photos.get_info() display(Photos_info) images_folder = dataiku.Folder('ABC12DDD') # pdf.image(im) pdf.image('/project/XX1111/ABC12DDD/apple.jpeg')
This is the error I get
RuntimeError: FPDF error: Missing or incorrect image file: /project/XX1111/ABC12DDD/apple.jpeg. error: [Errno 2] No such file or directory: '/project/XX1111/ABC12DDD/apple.jpeg
Answers
-
Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 2,160 Neuron
You can then list the contents of the folder, as paths relative to its root:
import dataiku folder = dataiku.Folder("folder_name") folder_paths = folder.list_paths_in_partition()
https://doc.dataiku.com/dss/latest/connecting/managed_folders.html#usage-in-python