Re: 문자열의 문자를 교체합니다.문자열은 동일한 패턴을 따르는 것으로 보입니다. 공백이나 "를 구분 기호로 사용하여 words() 함수를 사용할 수 있습니다. 그런 다음 concatitems()를 사용하여 다시 합치십시오.

Re: 문자열의 문자를 교체합니다.정규식은 또 다른 옵션입니다.
Regex(:Results, "(BIN = \!".+\!") (\d+)(\!".+)", "\1 " || Char(:Count) || "\3")
그러나이 경우 Craige가 제안한 것처럼 Words() + Concat Items()를 사용합니다 (패턴이 항상 동일한 경우)
Re: 문자열의 문자를 교체합니다.Craig와 Jarmo에게 감사드립니다.
Re: 문자열의 문자를 교체합니다.이 줄에 문제가 있다고 생각합니다.
x[4] = Char( arra[binxx[j]] );
연관 배열 + 행 대신 행을 반복하도록 루프를 수정합니다.
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: 문자열의 문자를 교체합니다.감사합니다
Re: 문자열의 문자를 교체합니다.@jthi
Cragis 논리를 사용하여 문자열의 카운트를 업데이트했지만 올바른 카운트 문자열을 대체하지 않습니다. 내가 뭘 잘못하고 있는지 잘 모르겠습니다. 제 코드 좀 봐주실 수 있나요?
잘못된 개수 할당
코드는 다음과 같습니다.
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 );
)
)
);
문자열의 문자 바꾸기안녕하세요 JMP 커뮤니티,
문자열이 있는 열을 가져오고 각 행에서 개수를 개수 열의 값으로 바꾸는 jsl 코드를 작성하려고 합니다. 최종 결과는 결과 열과 유사해야 합니다.
어떤 제안?
자동화 및 스크립팅