Re: Sostituire i caratteri nella stringaLe corde sembrano seguire lo stesso schema. Forse usa la funzione words() con uno spazio o " come separatore. Quindi usa concatitems() per rimetterlo insieme.

Re: Sostituire i caratteri nella stringaRegex è un'altra opzione
Regex(:Results, "(BIN = \!".+\!") (\d+)(\!".+)", "\1 " || Char(:Count) || "\3")
ma in questo caso userei Words() + Concat Items() come suggerito da Craige (se lo schema è sempre lo stesso)
Re: Sostituire i caratteri nella stringaGrazie Craig e Jarmo
Re: Sostituire i caratteri nella stringaPenso che il problema sia con questa linea
x[4] = Char( arra[binxx[j]] );
Modificherei il ciclo per eseguire il ciclo sulle righe anziché sull'array associativo + righe:
Names Default To Here(1);
dt = Current Data Table();
/// Get list of all the bins
binxx = Associative Array(:Bins[23 :: N Rows(dt)]) << Get Keys;
delcols = {"", " ", "}"};
/// Remove garbage values
For(i = 1, i <= N Items(delcols), i++,
Remove From(binxx, As List(Loc(binxx, delcols[i])));
);
///Get rows where Bins column contains BIN =
rows = dt << get rows where(Contains(:Bins, "BIN = "));
total = {};
//Loop to calculate the count of each bins
For(i = 1, i <= N Items(binxx), i++,
Insert Into(total, N Items(dt << get rows where(:Bins == binxx[i])))
);
//create array to store bin and counts
arra = Associative Array(binxx, total);
//loop to modify the character count in the table
For(i = 1, i <= N Items(rows), i++,
x = Words(:Bins[rows[i]]);
curbin = Substitute(x[3], "\!"", "");
If(Contains(arra, curbin),
x[4] = Char(arra[curbin]);
:Bins[rows[i]] = Concat Items(x);
,
continue();
);
);Re: Sostituire i caratteri nella stringaGrazie mille Jarmo
Re: Sostituire i caratteri nella stringa@jthi
Ho usato la logica di Cragis per aggiornare il conteggio nella stringa ma non sostituisce la stringa di conteggio corretta. Non sono sicuro di cosa sto facendo di sbagliato. Puoi dare un'occhiata al mio codice?
Assegna conteggi errati
Ecco il codice:
dt = Current Data Table();
/// Get list of all the bins
binxx = Associative Array( :Bins[23:: N Rows( dt )] ) << Get Keys;
delcols = {"", " ", "}"};
/// Remove garbage values
For( i = 1, i <= N Items( delcols ), i++,
Remove From( binxx, As List( Loc( binxx, delcols[i] ) ) );
);
///Get rows where Bins column contains BIN =
rows = dt << get rows where( Contains( :Bins, "BIN = " ) );
total = {};
//Loop to calculate the count of each bins
For( i = 1, i <= N Items( binxx ), i++,
Insert Into( total, N Items( dt << get rows where( :Bins == binxx[i] ) ) )
);
//create array to store bin and counts
arra = Associative Array( binxx, total );
//loop to modify the character count in the table
For( j = 1, j <= N Items( binxx ), j++,
For( i = 2, i <= N Items( rows ), i++,
If( Contains( arra, Substr( :Bins[i], 8, 1 ) ),
x = Words( :Bins[rows[i]] );
x[4] = Char( arra[binxx[j]] );
:Bins[rows[i]] = Concat Items( x );
)
)
);
Sostituisce i caratteri nella stringaSalve comunità JMP,
Sto cercando di scrivere un codice jsl che prenda una colonna con una stringa al suo interno e, in ogni riga, sostituisca il conteggio con i valori nella colonna del conteggio. I risultati finali dovrebbero apparire come nella colonna Risultati
Eventuali suggerimenti?
Automazione e scripting