Creazione di nuove colonne dai dati in una esistenteHo un grande set di dati con una delle colonne di dati contenenti celle con il formato seguente. C'è un modo per estrarre i diversi 'AppNames' in 3 colonne separate. Ho provato la funzione Testo in colonne in Utilità, ma non tutte le celle nella colonna hanno più di un nome app elencato o potrebbero avere informazioni leggermente diverse incluse e che getta via l'allineamento e finisco per ottenere valori errati nelle mie nuove colonne ... Idealmente, posso usare la stringa 'AppName:' come 'delimitatore'? Quindi, dall'esempio seguente ... Dovrei finire con tre nuove colonne - con i dati che si riferiscono ad Application1, Application2 e Application3 ... grazie
Formato
tx: AppID: 32734, tx: AppName: Application1 , tx: ServerEnv: sviluppo, tx: ServerStatus: distribuito, tx: OwningVP: xxxxxxxxx, tx: DevMgr: xxxxxxxxx, tx: OwningDirector: xxxxxxxxx, tx: AppOwner: xxxxxxxxx, tx: BusinessOwner: xxxxxxxxx, tx: SOX: No, tx: SOX: No : PCI: No, tx: L5_MGR: xxxxxxxxx, tx: DataClass: uso interno, tx: DRClass: Classe I, tx: AppType: IT supportato, tx: OrgL2: TSO, tx: OrgL3: TMX, tx: OrgL4: Mobile e VC, tx: AppID: 655369, tx: AppName: Application2 , tx: OwningVP: xxxxxxxx, tx: DevMgr: xxxxxxxx, tx: OwningDirector: xxxxxxxx, tx: AppOwner: xxxxxxxx, tx: BusinessOwner: xxxxxxxxx, tx: SOX: KFS Tier 2, tx :: KBA Tier 1, tx: DataClass: Limitato, tx: OrgL2: CBS, tx: OrgL3 :, tx: tx: AppID: 655364, tx: AppName: Application3
Ri: Creare nuove colonne da dati in uno esistenteHo adottato un approccio leggermente diverso al tuo problema. Guardando i tuoi dati, mi sono reso conto che quello che hai sono molte colonne diverse, con le righe come applicazioni. Quindi ho scritto una piccola sceneggiatura che spezza tutto questo. Ora il problema è che ci sono errori nei dati. Quindi ho aggiunto un'area all'interno del codice che tenta di risolverli. Non avendo tutti i tuoi dati, sono sicuro che potrebbero esserci più correzioni da inserire. Una volta inseriti questi dati, se si desidera che i dati vengano ancora allineati in 3 colonne, è possibile eseguire facilmente una trasposizione dei dati in 3 colonne.
Names Default To Here( 1 );
theData =
"tx:AppID:32734, tx:AppName:Application1, tx:ServerEnv:Development, tx:ServerStatus:Deployed, tx:OwningVP:xxxxxxxxx, tx:DevMgr:xxxxxxxxx, tx:OwningDirector:xxxxxxxxx, tx:AppOwner:xxxxxxxxx, tx:BusinessOwner:xxxxxxxxx, tx:SOX:No, tx:PCI:No, tx:L5_MGR:xxxxxxxxx, tx:DataClass:Internal Use, tx:DRClass:Class I, tx:AppType:IT Supported, tx:OrgL2:TSO, tx:OrgL3:TMX, tx:OrgL4:Mobile and VC, tx:AppID:655369, tx:AppName:Application2, tx:OwningVP:xxxxxxxx, tx:DevMgr:xxxxxxxx, tx:OwningDirector:xxxxxxxx, tx:AppOwner:xxxxxxxx, tx:BusinessOwner:xxxxxxxxx, tx:SOX:KFS Tier 2, tx::KBA Tier 1, tx:DataClass:Restricted, tx:OrgL2:CBS, tx:OrgL3:, tx: tx:AppID:655364, tx:AppName:Application3";
dt = New Table( "The Table" );
dt << delete columns( "Column 1" );
word# = 1;
While( Word( word#, theData, "," ) != "",
colNameList = dt << get column names( string );
theWord = trim(Word( word#, theData, "," ));
// Make found corrections
If( Trim( Word( 2, theWord, ":" ) ) == "tx",
theword = Word( 2, theword, ":" ) || ":" || Word( 3, theWord, ":" ) || ":" || Word( 4, theWord, ":" )
);
If( word( 1, theWord, ":") == "", theWord = "tx" || theWord );
if( word( 2, theWord, ":") == "",
theword = Word( 1, theword, ":" ) || ":" || word(1,Word( 3, theWord, " " )," ") || ":" ||
substr(Word( 3, theWord, ":" ),length(Word( 3, theWord, ":" ))+2);
);
if( word( 3, theWord, ":") == "",
theword = Word( 1, theword, ":" ) || ":" || word(1,Word( 2, theWord, ":" )," ") || ":" ||
substr(Word( 2, theWord, ":" ),length(Word( 1, Word( 2, theWord, ":" ), " " ))+2);
);
if(word(2,theword,":")=="KBA",show(theword));
colName = Word( 2, theWord, ":" );
If( Word( 2, theWord, ":" ) == "AppID",
dt << Add Rows( 1 );
);
If( N Rows( Loc( colNameList, colName ) ) == 0,
dt << New Column( colName, character );
);
Column( dt, colName )[N Rows( dt )] = Word( 3, theWord, ":" );
word#++;
);
Ri: Creare nuove colonne da dati in uno esistenteGrazie Jim ... Immagino che ciò che sto cercando di fare sia estrarre i dati "AppName" dalla colonna "Tag asset" e inserirli in nuove colonne (Applicazione n. 1, n. 2, n. 3). Vedi screenshot di seguito.
(Nome app: Exchange 2013 (350578) dai tag asset nella riga 1 di seguito)
Alcune delle righe nella colonna "Tag degli asset" hanno più di un AppName incluso e, purtroppo, non sono uniformi, vedere gli esempi seguenti:
Esempio di formato 1 (1 AppName)
tx: AppID: 350578, tx: Nome app: Exchange 2013 (350578), tx: ServerEnv: Production, tx: ServerStatus: In Maintenance, tx: OwningVP: xxxxxxxxx, tx: DevMgr: xxxxxxxxx, tx: OwningDirector: xxxxxxxxx, tx: AppOwner: xxxxxxxxx, tx: BusinessOwner: xxxxxxxxx, tx: SOX: No, tx : PCI: No, tx: L5_MGR: xxxxxxxxx, tx: EMEABanking: KBA Tier 2, tx: DataClass: High Restricted, tx: DRClass: Class I, tx: AppType: IT Supported, tx: OrgL2: TSO, tx: OrgL3: TMX, tx: OrgL4: Gestione dei messaggi e dei contenuti
Esempio di formato 2 (3 nomi app)
tx: AppID: 32734, tx: Nome app: CITRIX (32734) , tx: ServerEnv: sviluppo, tx: ServerStatus: distribuito, tx: OwningVP: XXXXXXXXX, tx: DevMgr: XXXXXXXXX, tx: OwningDirector: XXXXXXXXX, tx: AppOwner: XXXXXXXXX, tx: BusinessOwner: tx: SO : PCI: No, tx: L5_MGR: XXXXXXXXX, tx: EMEABanking: KBA Tier 2, tx: DataClass: uso interno, tx: DRClass: Classe I, tx: AppType: IT supportato, tx: OrgL2: TSO, tx: OrgL3: TMX, tx: OrgL4: Mobile e VC, tx: AppID: 655369, tx: Nome app: EBOSS EMEA (655369) , tx: OwningVP: XXXXXXXXX, tx: DevMgr: XXXXXXXXX, tx: OwningDirector: XXXXXXXXX, tx: AppOwner: XXXXXXXXX, tx: BusinessOwner: XXXXXXXXX, tx: SOX: KFS Tier 2, tx: L5_MABXXXXXXX Livello 1, tx: DataClass: limitato, tx: OrgL2: CBS, tx: OrgL3: Dell Financial SVCS, tx: OrgL4: DFS Originations and Lease Servicing, tx: AppID: 655364, tx: Nome app: TVALUE (655364)
Esempio di formato 3 (1 AppName, ma formato diverso)
ext: AppName: Tensione , ext: PCI: N, ext: OrgL3: TMX, ext: L5_Mgr: xxxxxxxxx, ext: Owning_Director: xxxxxxxxx, ext: App_Owner: xxxxxxxxx, ext: Owning_Group: messaggistica e contenuto Mgmt, Dell-External, External, High, Prohibited_Services, DC Scan - External, tx: AppID: 2812, tx: AppName: Exchange 2010, tx: ServerEnv: Production, tx: ServerStatus: Deployed, tx: OwningVP: xxxxxxxxx, tx: DevMgr: xxxxxxxxx, tx: OwningDirector: xxxxxxxxx, tx: AppOwner: xxxxxxxxx, tx: BusinessOwner: xxxxxxxxx, tx: SOX: No, tx: PCI: No, tx: L5_MGR: xxxxxxxxx, tx: EMEABanking: No, tx: DataClass: Altamente limitato, tx: DR Classe: Classe I, tx: Tipo di app: IT Supportato, tx: OrgL2: TSO, tx: OrgL3: TMX, tx: OrgL4: Messaggi e contenuto Mgmt
Nota: la colonna Applicazione n. 1 di seguito è stata creata utilizzando la funzione Testo su colonna in Col> Utilità ...
Non sono sicuro se spiegarlo bene ;-(

Ri: Creare nuove colonne da dati in uno esistenteCredo che questo codice farà quello che vuoi. In allegato è presente una tabella di dati, con le 3 righe degli esempi forniti. Lo script seguente gestisce le estrazioni multiple di applicazioni
Names Default To Here( 1 );
dt = Current Data Table();
dt << New Column( "Application #1", character );
dt << New Column( "Application #2", character );
dt << New Column( "Application #3", character );
For( theRow = 1, theRow <= N Rows( dt ), theRow++,
word# = 1;
appName# = 1;
While( Word( word#, :Asset Tags[theRow], "," ) != "",
theWord = Trim( Word( word#, :Asset Tags[theRow], "," ) );
If( Word( 2, theWord, ":" ) == "AppName",
Column( dt, "Application #" || Char( appName# ) )[theRow] = Word( 3, theWord, ":" );
appName#++;
);
word#++;
);
);
Ri: Creare nuove colonne da dati in uno esistenteEcco un approccio leggermente diverso che include l'aggiunta dei valori alla tabella. Nella parte superiore del codice ho una funzione di analisi simile a parole , ma i delimitatori possono essere multi-carattere.
//------------------------------------------------------------------------------
/*
Function Name: my_parse
Description: Parse text according to a given delimiter. Two delimiters in a row
will yield an empty list entry, which is different from the behavior
of WORDS
Returns: list of tokens
Arguments:
_text Text to determine be parsed
_delim Delimiter
*/
my_parse = function({_text, _delim},
{Default Local},
pname = "get_words";
if (is missing(_text),
// then
ret_list = {};
,
// else if
_text == "",
ret_list = {};
,
// else we've got some text to work with
ret_list = {};
len_delim = length(_delim);
istart = 1;
keep_going = 1;
while (keep_going,
iend = contains(_text, _delim, istart);
if (!iend,
keep_going = 0;
insertinto(ret_list, substr(_text, istart), 1);
,
insertinto(ret_list, substr(_text, istart, (iend - istart)), 1);
istart = iend + len_delim;
);
);
);
reverse(ret_list);
); // end my_parse
//------------------------------------------------------------------------------
dt = current data table();
dt << new column("Application #1", character);
dt << new column("Application #2", character);
dt << new column("Application #3", character);
for(i = 1, i <= nrows(dt), i++,
one_asset = dt:asset tags[i];
one_list = my_parse(one_asset, ", ");
app_list = {};
m = 0;
for (k = 1, k <= nitems(one_list), k++,
one_item = one_list[k];
aloc = contains(one_item, "AppName:");
if (aloc,
m++;
app_list[m] = substr(one_item, 8 + aloc);
);
);
show(app_list);
// Now add these to the respective Application # columns
for (k = 1, k <= nitems(app_list), k++,
cname = "Application #" || char(k);
column(dt, cname)[i] = app_list[k];
);
);