如何將資料解析為列,然後將它們與多個特殊字元堆疊在一起我有一個原始資料需要將文字發送到包含許多特殊字元的列,然後將它們堆疊起來。您能否協助透過 JSL 腳本提供針對一般情況的解決方案。請幫忙參考我的excel文件以了解詳細信息
自動化和腳本編寫回覆:如何將資料解析為列,然後用多個特殊字元堆疊它們非常感謝吉姆提供的解決方案。
盛
回覆:如何將資料解析為列,然後將它們與多個特殊字元堆疊在一起這是我的第一個pass腳本。該方法應該為您提供所需的信息,以查看完整的數據表可能需要調整的內容
Names Default To Here( 1 );
dt = Current Data Table();
// Create the new columns
dt << New Column( "domain_frequency_core", character );
dt << New Column( "Data" );
// Create the static part for the column domain_frequency_core
startString = "Data@" || Word( 1, :string_result[1], ":" );
// Read into a memory variable the entire string, minus the startString component
theString = Word( 2, :string_result[1], ":_" );
// Initialize the looping variables
outerLoop = 1;
theRow = 0;
// Loop through the major groupings in the data
While( Word( outerLoop, theString, "%" ) != "",
// Strip off the subpart of the string
majorWord = Word( outerLoop, theString, "%" );
// Get the second component of the start string
startStringSuffix = "@" || word(1,majorWord,"^") || "@";
// Initialize the inner loop value, starting with word 2
innerLoop=2;
// Loop through the subgroup finding each numeric component
While( word(innerLoop, majorWord, "^V") != "",
// Add a new row
if(theRow !=0, dt<<ADD rows=""></ADD>
<P><SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1712831359209.png" style="width: 668px;"><span class="lia-inline-image-display-wrapper" image-alt="txnelson_0-1712831359209.png" style="width: 668px;"><img src="https://us.v-cdn.net/6038925/uploads/images/63259i1123569D89D26136/txnelson_0-1712831359209.png" width="668" height="330" role="button" title="txnelson_0-1712831359209.png" alt="txnelson_0-1712831359209.png" /></span></SPAN></P>
<P> </P>回覆:如何將資料解析為列,然後用多個特殊字元堆疊它們嗨吉姆,
看來您誤解了我的數據,您寫的程式碼就是輸出。
請幫助參考表“原始數據”

工作表「解析後的資料」中的預期輸出

先感謝您。
回覆:如何將資料解析為列,然後用多個特殊字元堆疊它們下面的腳本將取得原始資料表並拆分出目標列,然後堆疊結果。鑑於某些拆分列僅由字串資料組成,而某些列似乎是數值,因此所有列的堆疊似乎不是您想要的。
Names Default To Here( 1 );
dt = Current Data Table();
targetCol = "domain_frequency_core";
// Text to columns
Data Table( "Book1 (4)_Sheet1" ) <<
Text to Columns( columns( Column( targetCol ) ), Delimiters( "@" ) );
// Get list of all target columns except original column
stackList = Filter Each( {name}, dt << get column names( string ),
Contains( name, targetCol ) & name != targetCol
);
// Stack the new columns
dt << Stack(
columns( stackList ),
Source Label Column( "Label" ),
Stacked Data Column( "Data" ),
Output Table( "Final Stacked Data Table" )
);
請花點時間研究劇本。所使用的所有功能和平台均記錄在腳本索引和 JMP 幫助畫面中。