cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
lala
Level VII

How to organize this non-standard form?

Thanks Experts! I'll just sort it out the stupid way and see if there's a better way.

dt = Current Data Table();
ca = "这";
Column( ca ) << Formula(
	If( Left( 是, 1 ) == "#",
		r = Row();
		a = Substitute( 是, "#", "" );
		"";
	,
		b = Row() - r;
		If( a != "拉丁" | a != "拉丁" | a != "假名" | a != "數字、分數",
			Word( b, a, "、" ),
			a || Munger( 是, 3, 1 )
		);
	)
);
dt << run formulas;
Column( ca ) << deleteFormula;

20240515223138.png

 

2 REPLIES 2
lala
Level VII

回复: How to organize this non-standard form?

The difficulty here is that the number of headings does not match the number of lines. Is there a better way to handle this?
Thanks!

2024-05-15_22-43-40.png

jthi
Super User

Re: How to organize this non-standard form?

I'm not exactly sure how you want to fill those rows but here is a guess

Names Default To Here(1);

dt = Open("$DOWNLOADS/symbols.jmp");
newcol = dt << New Column("header", Character, Nominal);
dt << Move Selected Columns(newcol, To First);
Column(dt, 2) << Set Name("symbol");

cur_headers = {};
cur_header = "";

dt << Begin Data Update;
For Each Row(dt,
	If(Starts With(:symbol, "#"), // Header row
		cur_headers = Words(:symbol, "#、");
		cur_header = "";
	,
		If(N Items(cur_headers) > 0,
			cur_header = Remove From(cur_headers, 1)[1];
		);
	);
	:header = cur_header;
);
dt << End Data Update;

jthi_0-1715786146076.png

 

-Jarmo