Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
pascos88
Creator II
Creator II

How change the name of attribute in a fild

Hello,

I need to change the name of attribute in a table through script.

ex

ID      Name

1       Mark

2       Paul

3       Michael

4      Manu

5      Julien

I need to have Mark as Marcus and Manu as Manuel.

How I can do it in the script?

Regards

Pasquale

I attached my App. My goal is rename Turbine field WTG01 as E1 WTG02 as E2 .... WTG06 as E6 so In the List Box Turbine I will have just E1, E2,E3,E4,E5,E6 Regards Pasquale

10 Replies
arulsettu
Master III
Master III

may be this

test:

LOAD * Inline [

Name

Mark

Paul

Michael

Manu

Julien

];

LOAD Name,

if(Name='Mark','Marcus ',

if(Name='Manu','Manuel',Name)) as new

Resident test;

jonathandienst
Partner - Champion III
Partner - Champion III

Create a mapping of abbreviated vs full names and use ApplyMap. Then if  new abbreviation needs to be added, just add a row to the mapping table before loading the main table:

MapFullNames:

Mapping LOAD *

Inline

[

     Abbr, Full

     Mark, Markus

     Manu, Manuel

];

Main:

LOAD ID,

     Name As Abrev,

     ApplyMap('MapFullNames', Name) As Name

     ...

(Names not in the table will not be changed)

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Peter_Cammaert
Partner - Champion III
Partner - Champion III

By using a Mapping table.

Define a mapping table with two columns: original name and translated name. You can store these names in an external file to avoid changing your script every time a name should be added/changed.

Use applymap() to translate original names to new names wherever you read names from an external source. For example:

LOAD

:

applymap('MyMapTable', OriginalName) as TranslatedName,

:

FROM ...;

will translate the name if it is present in your mapping table, and will keep the original name if not.

Best,

Peter

Not applicable

Hi Pasquale,

I will do as follows:

// First step: import data

mytable:

LOAD * INLINE [

ID,      Name

1,       Mark

2,       Paul

3,      Michael

4,      Manu

5,      Julien

];

//Second step: export data

Store mytable into xyz.txt (txt);

//Last step: import data exported and recoding

LOAD

     ID,

     Name,

     if(Name='Mark', 'Marcus', if(Name='Manu','Manuel', Name)) as [Name recoded]

FROM

D:\users\F66339A\Desktop\xyz.txt

(txt, utf8, embedded labels, delimiter is ',', msq);

Step 1 and 2 are needed only in case of INLINE import of your data.

Hope it helps.

All the best,

Sabrina

jagan
Luminary Alumni
Luminary Alumni

HI,

Try like this using Mapping Load

NamesMapping:

MAPPING LOAD

*

INLINE [

ActualName, NewName

Mark, Marcus

Manu, Manuel];


Data:

LOAD

ID,

ApplyMap('NamesMapping', Name, 'N/A') AS Name

FROM DataSource;


This is the best practice, when there is a change you can just change in the above inline table or you can maintain this in Excel or in Database and load this from that.


Hope this helpsyou.


Regards,

Jagan.

Anonymous
Not applicable

Do like this at script level:

Load

ID,

if(Name='Mark', 'Marcus',

if(Name='Manu', 'Manuel', Name)) as Name

From TableName;

Not applicable

Hi,

you can use "pick" function.

eg. pick(match(Name,'Mark','Manu'),'Marcus','Manuel') AS Name

pascos88
Creator II
Creator II
Author

How I can attach my App in a discussion already started?

maybe is better that I share the app in order to better understand what I need.

Peter_Cammaert
Partner - Champion III
Partner - Champion III

You can attach files to any reply you post in a discussion thread. When writing your post, select Advanced Editor (top right link), and in the editor select Attach (bottom right link).

Even after you've submitted a reply, you can still attach files by selecting Actions->Edit which will open the Advanced Editor by default.