replace bookmarks in text file - cakephp-3.0

We have a bunch of emails that need to be code-generate using data stored in database. Body for emails are stored in an XML file (could be moved to json or table). I like to use some sort of bookmarks (created using their corresponding table/field name) and then populate them.
For example:
*Good day:
This is the initial communication to a <<**order_no**>>, please ensure the communication
is consistent through this thread.
Please find herein links to business requirements for: <<**project_name**>>
BR # <<**br_no**>>
PRJ # <<**project_no**>>*
How do I read the XML file?
How do I manipulate the text?
Thank you!

Related

Import Folder of Documents into Container field via script

Im running Filemaker Server 19 and FileMaker 19 client
I have an app that manages Document Templates, ie Word documents
Each Document Template master record contains information about that template, plus connects to a Document Samples table that contains one Word document (the template) and one PDF document (an output of the template file when used , a bit like mail merge).
We've recently had an update to the system I support (not a Filemaker system) and many hundreds of the Word templates have been updated. If I have to do one or two in a session it's pretty simple to drag the latest version of each template to the Container field; but recently I've been having to do 10s/100s of Document updates very quickly to get them into our system. I've put copies of all the Word documents into a folder on my Mac. They all have a unique name and a unique template id in the format of 1234doctemplate01. So, the 1234 equates to my Document template ID in my database and the filename is also mirrored in a 'Template Name' field in the database.
So, my question is how to build a Script to go through the database one record at a time and, for each, to check the Mac folder and see if there's matching document name and, if there is, to paste/copy it into the appropriate Container field
Can anyone advise, please? Further detail available if this isn't too clear
I would do something slightly different:
Import all the files in the folder into a new table (see https://help.claris.com/en/pro-help/content/importing-folder.html) and create a relationship between this table and your existing table, based on matching template ID or name.
Then you can loop over the records in either table and if a match is found, replace the data in the existing container. Or perhaps you could make this a permanent structure, where the file is stored in a related record.
Doing it the way you have proposed would be awkward using only Filemaker's built-in tools (and outright impossible if the folder is not somewhere within the Documents folder). It might be somewhat easier if you use a plugin (e.g. BaseElements) to read the folder's contents.
You can use base element plugin to select multiple files in a folder with
BE_FileSelectDialog
or check if a file exist with
BE_FileExists
and then looping over the list to insert every file into a container via
set field ["your_container" ; BE_FileImport ( $file )]

In Power Automate, how to get data from a .csv email attachment and format it for display?

1st time posting a question...
I have a simple task in Flow - I need to get data from a .csv email attachment, format it in an html table, and then send it in another email. I've seen several paid connectors and some other methods to "parse" the .csv data to create a JSON array - is the the best solution?
Trigger is "when an email is received."
.
.
.
Output is "send an email"
Any help is much appreciated!
You could use Encodian's Parse CSV connector, it's free, but you need to create a free account with them.
The one thing I've noticed is that you might need to place the CSV Data value that it produces into an expression with a json() function to ensure that it is properly read. This is because the Flow HTML Table action detected the result from my test as a string, despite encodian stating it was JSON.
json(outputs('Parse_CSV')?['body/csvData'])
That is how it would look if you've changed none of the names of any of the actions.
As you say, there are many CSV connectors out there, the ones that mention JSON are simply formatting the result in to something that Flow can understand and work with in some ease.
Here is my flow, obviously yours will have the incoming email as the result, not the button.

Multiple entries containing exact file paths or text file on server containing multiple file paths with a single entry in the database to that file?

Here's some background information to help understand my dilemma. I've got a system written in PHP where users can fill out a form, upload a few images and everything gets archived in a .zip, I then have an "Account Page" that echo's a simple table containing a list of all of that specific users uploaded .zip's, the reason I'd need separate filepaths for each and every .zip is because no matter the user, they all need to be in the same single folder on the server for the broader application to work (these .zips are used for a mobile based Package Manager; see Cydia).
Would the smarter choice be to have every name of each .zip stored in a table on the database with things like the username and user_id tying to each entry, which would result in a few entries being for one user, and a few more being for a different user (depending on upload time), and everything will be unorganized. If I need to enter the database and manually search for a specific user's uploaded .zip's, I'll have to sort them out by user_id.
OR
Would it be more cost effective (in terms of passing data and hardware limitations) to have an XML file or even a plain .txt file on the server with a list of the users uploaded .zip's, and an exact file path pointing to them, and in the database simply have one column tied to the rest of the users information that points to that file containing multiple lines of filepaths?
It's a mouth full I know, and I have no problem achieving either of them as it's well within my skillset and knowledge of PHP & MySQL, I'm just not too sure which is the most secure and the best practice in the industry for this type of system.

Puppet - CSV file header

I'm, writing a Puppet (3.6.2) module that reads data fields from a CSV file via the extlookup function and I cannot figure out how to tell extlookup that the first line is the header field. Does extlookup support this? If not, can anyone recommend an external function I could import and use?
thanks,
PS - Yes I know about hiera, and having the data in YAML or JSON files but my requirement is CSV files only.
Brandon
The behavior of extlookup() is pretty well documented. It makes no special provision for column headers, which are by no means an inherent feature of CSV format. Indeed, if your header line is not readable as a data line, then your file is not CSV at all.
Supposing that your file is indeed valid CSV, the absolute simplest solution would be to ignore the issue. It presents a problem only if the first column heading duplicates an actual or potential data name. If it does not, then you will never look up or use the psuedo-value represented by the first row.
If your file in fact is not CSV on account of its first line, or if the first column name conflicts with a real data name, then it seems the next best alternative would be to just remove that line, or to avoid creating it in the first place. I don't see any reason why one of these should not be possible.
I know about heira, and having the data in YAML or JSON files but my requirement is CSV files only.
How sad. Do be aware that extlookup() has long been deprecated, and it was removed from Puppet 4.
I'm inclined to suggest you implement a translator from CSV to Hiera-friendly YAML, and use Hiera in your module. Alternatively, Hiera supports custom backends, and it's not too hard to write one. I am unaware of an existing CSV backend for Hiera, but you could write one. Ignoring a header line would then be under your control, and you would simultaneously achieve a measure of future-proofing.

csv file upload

In my Grails app, I would like admin users to be able to upload a CSV file that contains data such as:
List of users to be added to system
List of groups to be added to system
Assignment of users to groups
I have no idea how the user will generate these CSV files - most likely from Excel, Access or similar, and therefore I've no way of knowing which column will contain which data. So I'm planning to allow the user to specify which column contains users, groups, etc.
I'm wondering if there's a JavaScript component that could help with this. Ideally I'd like to implement the following:
User uploads file
In browser, user is shown first N lines of uploaded file and prompted to select the column that contains the users, groups, etc.
Column information is uploaded to server
Is there a client/server side component that could help with this, or an entirely different approach which would be superior to that outlined above?
I should emphasise that the users of this system will not be technically gifted, so expecting them to provide an XML/JSON file instead is out of the question (and you can definitely forget about asking them to call a Web Service instead of uploading a file).
Thanks,
Don
I like your solution so far, given that the users are non-technical, and that you want to be able to accept this data as a file upload, rather than have the users enter it directly into your application.
I would simply suggest that when the user uploads the file, the server returns the first five (or so) lines back to the client as an HTML table. Then you can have <select> drop-downs as the headers for each column, with the pre-set options you're looking for. You can validate that the user has assigned all available options to each column (use JS to remove options from the select as they use them, but be sure to provide a method to undo and change selections), and allow some columns not to be labeled (which the server will just ignore when parsing the file.
If possible, also illustrate (perhaps in a graph format or just an example sentence, if applicable) how their label choices will apply to the relationships. For example, "New user ABC will be a member of new group XYZ." If ABC and XYZ are unexpectedly backwards, the user will recognize they made a mistake.
Also, some users will inevitably upload a file where they used rows as columns and columns as rows. Either provide a GUI function to reverse this ("rotate" the table), or let them choose which axis to label.
I would also suggest providing your users with a collection of example files in various formats (Excel, Access, etc), and give them explicit instructions for how to enter the data they want, and step by step instructions to export as CSV and upload.
I have no idea how the user will generate these CSV files - most likely from Excel, Access or similar, and therefore I've no way of knowing which column will contain which data.
I should emphasize that the users of this system will not be technically gifted
With these two things in mind, are you sure that CSV import is the best way to handle bulk user creation? It's a great technical solution, but the question is, will your users be able to take advantage of it?
It may be worth implementing an alternative bulk create option for those who don't get CSV or are scared off by Excel. Perhaps a JS grid that has the required fields where they could manually enter the data for each field and enter as many as they need at once, with a link to upload a CSV file as an option for those who would use it.
For the CSV option, since your users are not technically-minded, it would be better to give them instructions on how to create the csv files that specify the order fields should be in. Along with a screen shot and a sample file.
Another option is to require the field names be the first row of the document, and require that they use specific labels for the fields. If you do that, you could figure out from the first row what order the data is in. You could also put in a check that looks for the titles in the first row and if they're not found, tell the user they need to add the field names to the CSV and re-upload.