Hello,
I have a DocType in my app that has a required Attach fieldtype for a csv file.
I need to access this file to run some validation when submitting or updating this DocType.
Currently I have the following method in the DocType controller class:
def get_csv(self):
doc = frappe.get_last_doc(doctype='File', filters={'attached_to_name': str(self.name)})
file = doc.get_full_path()
with open(file) as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',')
# do the things we need
Is this the best/recommended way of accessing the attached file? I wanted to use the get_content method on the File controller class but it doesn’t seem to be completed yet.
Thank you for any feedback!