I am trying to create a single data mapper for 2 different types of data input (csv) all field headers are the same between the 2 files except 1 of the files has an additional header field.
How can I check to see if this field exists before extracting in datamapper?
I have a condition on my template based on if this field exists.
I’m not aware of a method to check the field before mapping. I suppose another Preprocessor script could be used. However I have encountered something like this before. My way of resolving this is to not have the mapper use the first row for field names. You need to extract them and name them yourself and set Lines To Skip to 1. I added the extract fields using the database with the most fields first. Then wrote a Preprocessor script that will add blank columns to the data. Do note that this method requires all databases columns/fields to be in the same order and the Preprocessor script will need to be run manually in the data mapper while you are designing your template each time the data mapper is opened.
I have it in datamapper as a conditional javascript. It will return false for data that doesn’t contain the suspect_field header or true for data that does contain it and extract the contents of the field.