Capitalize Column name using Script

    Hi All,


    When we write script then many time we use upper(Column) or Capitalize(Column) in our script.. this is used more often when we have XL data source.


    In one of my recent development i have to load data from xl files where i have multiple table and there is inconsistency in the column names, some were in upper case, some were in lower case and some were in capitalized.


    There were around 30 odd tables and each table is having more than 20 columns. so it was bit tedious job to check and rename every field for the consistency in names..


    So here is the solution :


    a simple script and job is done.


    below is the sample code which you can use in your code accordingly..



    LOAD * Inline







    // Main Code

    let Field = '';

      for i=1 to NoOfFields('Src');

      let Field = '$(Field)'& if(len('$(Field)')>0, ',' & chr(10), '')& '[' & FieldName($(i), 'Src') & ']'& ' as ' & '[' & Capitalize(FieldName($(i), 'Src')) & '] ';

      NEXT i;


    rename table Src to TMP;


    NoConcatenate load


    Resident TMP;

    DROP Table TMP;

    //End of Main Code


    Hope this code will help you... instead of capitalize we can use lower or upper as per requirement