cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
Jackie_
Level VI

Import x and y values from the text file to jmp table

Hi,

 

Reading each line in text file and import each string as a separate row in the jmp data table 

 

 

27 REPLIES 27
Jackie_
Level VI

Re: Import x and y values from the text file to jmp table and create wafer map

It's a masterpiece. Thank you very much!

Jackie_
Level VI

Re: Import x and y values from the text file to jmp table and create wafer map

@jthi 
Just a quick question

The actual text file contains wafer information in the beginning. I want to store the data from row 21. I modified jsl as below. It does read as expected. Any suggestions?

Jacksmith12_1-1657306350593.png

			map_str = Load Text File();


			l = Words( map_str, "\!N" );
			rowc = N Items( l );
			colc = N Items( Words( l[21], "" ) ); //// edits

			dt = New Table( "Untitled",
				Add Rows( rowc * colc ),
				New Column( "X", Numeric, Continuous ),
				New Column( "Y", Numeric, Continuous ),
				New Column( "bin", Character, Nominal, Label( 1 ) )
			);

			For Each( {line, idx}, l,
				cur_rows = ((idx - 1) * colc :: (idx * colc - 1)) + 1;
				dt[cur_rows, "X"] = ((1 :: colc))`;
				dt[cur_rows, "Y"] = (J( 1, colc ) * (idx))`;
				dt[cur_rows, "bin"] = Words( line, "" );
			);

 

jthi
Super User

Re: Import x and y values from the text file to jmp table and create wafer map

You should use some method to get only the wafermap (if you only care about it). Currently you are using the whole text file. Some options for that are

  • Regex
  • Substr with Contains
  • Words and split on {}
  • Words and split on row change and combine that with Contains to
  • hard coding lines and getting wafermap based on those (usually very bad idea)
-Jarmo
Jackie_
Level VI

Re: Import x and y values from the text file to jmp table and create wafer map

Sorry to bother you again. I tried substr  but there's something not correct in the code. If you could modify, it would be great

			map_str = Load Text File();


			l = Words( map_str, "\!N" );
			rowc = N Items( l );
			colc = N Items( Words( l[21], "" ) ); //// edits

			dt = New Table( "Untitled",
				Add Rows( rowc * colc ),
				New Column( "X", Numeric, Continuous ),
				New Column( "Y", Numeric, Continuous ),
				New Column( "bin", Character, Nominal, Label( 1 ) )
			);

			For Each( {line, idx}, l,
				cur_rows = ((idx - 1) * colc :: (idx * colc - 1)) + 1;
				dt[cur_rows, "X"] = ((1 :: colc))`;
				dt[cur_rows, "Y"] = (J( 1, colc ) * (idx))`;
				dt[cur_rows, "bin"] = substr( line, 1 );
			);

 

jthi
Super User

Re: Import x and y values from the text file to jmp table and create wafer map

You need to manipulate the string you get from Load Text File() in such a way that you end up with string which contains only the wafermap part of the text file. This won't give final string needed but gives one idea what you could do. See Scripting Index (and JMP Help) on how Substr and Contains work. It also has one option on using Words and Contains, which also needs some modifications to get correct list.

Names Default To Here(1);

demo_str = "SOMETHING
TEXT
EXAMPLE
MAP = {
.X.
XXX
.X.
}";

map_str = Substr(demo_str, Contains(demo_str, "MAP = {"));
show(map_str);

stop();
demo_list = Words(demo_str, "\!N");
map_start = Contains(demo_list, "MAP = {");
map_list = demo_list[map_start::N Items(demo_list)];
show(map_list);

 

-Jarmo
Jackie_
Level VI

Re: Import x and y values from the text file to jmp table and create wafer map

That's good explanation @jthi .

 

Quick question: 

The below statement will start reading data from second row of the list. I don't want to read the last row which contains brace "}".

How can I define the end line in the script

 

 

map_str = Substr(demo_str, Contains(demo_str, ".X."));

 

 

 

txnelson
Super User

Re: Import x and y values from the text file to jmp table and create wafer map

map_str = Substr(
	demo_str,
	Contains( demo_str, ".X." ),
	Length( demo_str ) - Contains( demo_str, ".X." ) -1
);

Note: Look in the Scripting Index for definition and examples for the Stbstr() function

Jim
Jackie_
Level VI

Re: Import x and y values from the text file to jmp table and create wafer map

@txnelson ,

 

Your approach works if the pattern in the first row matches with the contain statement. I have several wafer maps which won't have same patterns. The only similarity is the wafer pattern starts at row number 21 in the text file. Is there a way to define the row number where the script will start reading?. I have attached a wafer map text file for reference (better view on note pad ++)

jthi
Super User

Re: Import x and y values from the text file to jmp table and create wafer map

You could try Contains with "MAP = {". This should give you the location of "MAP = {" in the string and then use that knowledge with Substr to get what you want

-Jarmo
jthi
Super User

Re: Import x and y values from the text file to jmp table and create wafer map

You could try Contains with "MAP = {". This should give you the location of "MAP = {" in the string and then use that knowledge with Substr to get what you want. Also check scripting index (and possibly JMP Help which you can open from Scripting Index) to understand how Substr (and other functions) work.

-Jarmo