sdavenport Posted March 26, 2018 Share Posted March 26, 2018 Is it possible to 'Trim' the headers of an External Data file? I have multiple external data files and all have inconsistent headers. Some headers have trailing spaces while other headers do not have trailing spaces. See highlighted (RED) text below where I attempted to use 'SetFieldValue' to replace the field content. But apparently this will only allow you to replace field values and not header values. inFile = PrimaryInputFile() // ---------------------------- // -------- XDF1 -------- // ---------------------------- if (inFile.search("SEG1")>-1) { xdf1 = "_SEG1_STANDARD_REV.csv"; } if (inFile.search("SEG2")>-1) { xdf1 = "_SEG2_MATINEE_REV.csv"; } if (inFile.search("SEG3")>-1) { xdf1 = "_SEG3_UPGRADE_REV.csv"; } if (inFile.search("SEG4")>-1) { xdf1 = "_SEG4_T1-T2_REV.csv"; } [color="Red"]if (xdf1 != ""){ xdf1 = new ExternalDataFileEx(xdf1, ",") xdf.ignoreNumericFieldNames=true for (var i=0; i<xdf1.fieldCount; i++) { xdf1.SetFieldValue(0, i, Trim(xdf1.GetFieldValue(0, i))) } }[/color] Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted March 26, 2018 Share Posted March 26, 2018 Right, you can only set a field value, not a field name in the header row. You might consider using a macro in Excel, or some other program, to remove spaces from the field names in your data files, before giving them to FusionPro. Quote Link to comment Share on other sites More sharing options...
sdavenport Posted March 27, 2018 Author Share Posted March 27, 2018 Thank you, Dan. I did end up doing as you suggested. Because of QC checks performed by our data department it isn't 'appreciated' if we have to alter the data that is passed to me. I do alter if necessary, as in this case. However, it would be good to have a FusionPro function that would do this internally. Thanks again... this forum is awesome for finding ways to get the job done!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.