如何将数据解析为列然后用多个特殊字符堆叠它们我有一个原始数据需要将文本转换为包含许多特殊字符的列,然后将它们堆叠起来。您能否帮助通过 JSL 脚本为一般情况提供解决方案。请帮助参考我的 excel 文件以了解详细信息
自动化和脚本回复:如何将数据解析为列然后用多个特殊字符堆叠它们非常感谢 Jim 提供的解决方案。
盛
回复:如何将数据解析为列然后用多个特殊字符堆叠它们这是我的第一遍脚本。该方法应该能让你了解完整数据表可能需要调整哪些内容
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 帮助屏幕中。