New in the Community? Get started here

Schneider Electric Exchange Community

Discuss and solve problems in energy management and automation. Join conversations and share insights on products and solutions. Co-innovate and collaborate with a global network of peers.

Register Now
EDC Forum
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Lt. Commander

Remove garbage from input files using a Powershell script in the context of a EDC job

Sometimes you may find your input files contains some garbage you would like to get rid off. This garbage may be caused by foreign characters (for example è rendered as é) or simply your data source is adding garbage to the data files.

In the following example the source meter creates xml files that contain the data. The files created to not conform to the <XML> specifications


The section surrounded by a red rectangle should be part of the header, not attributes for the root node node. The easiest approach would be to request the meters to be properly configured, so it would send well-formed files. Unfortunately, this is not always possible and if this is the case, then you need to clean the files before processing it.

In the above example, EDC would extract extract the data from the input file using a XML delimited file extract task, Because the input file is ill formed, it failed. To solve the problem a [Pre-process]>[Powershell Script processor task was added. The task calls the attached powershell script. The purpose of the script is:

- Replaces the node <data......> by <data>

- Moves the unedited file to a EndFolder

- Saves the edited file in the original folder and using the original name

The edited file is processed by the XML Extract task with no trouble, so EDC can continue keeping the data flow between meter and end system!

You can adapt the script to your specific needs. As mentioned before you may have an incorrectly rendered foreign character, or garbage bits introduced at random, or as in the above case, and ill-configured system. Hopefully in all these case you will find this posting useful!.

Tags (1)