<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: JSL FOR loop to check values in cells and remove the 7th character if there is one in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JSL-FOR-loop-to-check-values-in-cells-and-remove-the-7th/m-p/37965#M22229</link>
    <description>&lt;P&gt;I think you are making it too hard. &amp;nbsp;This ode should work&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For( n = 1, n &amp;lt;= N Col( dtWAPFile ), n++,
	colname = Column( n ) &amp;lt;&amp;lt; get name;
	For( k = 1, k &amp;lt;= N Rows( dtWAPFile ), k++,
		Column( dtWAPFile, n )[k] = Left( Column( dtWAPFile, n )[k], 6 )
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 11 Apr 2017 02:14:21 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2017-04-11T02:14:21Z</dc:date>
    <item>
      <title>JSL FOR loop to check values in cells and remove the 7th character if there is one</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-FOR-loop-to-check-values-in-cells-and-remove-the-7th/m-p/37964#M22228</link>
      <description>&lt;P&gt;This snippet below is a portion of my script. &amp;nbsp;At this point I have a data table and some of the cells on various rows have an extra special character in the 7th position...yeah weird dataset. &amp;nbsp;Some don't. &amp;nbsp;There are multiple rows and multiple columns, all of which can vary in count.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I'm using a FOR loop to check the value of each cell for each row and column then trim or remove the 8th character if it has it. &amp;nbsp;In fact, the script can simply do a left(dt,7) and I'd be happy with that. &amp;nbsp;Where I'm at though is stuck because when I use the GETVALUES function then it puts the cell values for that column in a matrix and I can't figure out how to do the left trim. &amp;nbsp;If I instead loop each row individually by removing the GETVALUES&amp;nbsp;then I can trim the value properly but can't figure out how to force the new value into the cell. &amp;nbsp;I have included both ways in the script below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;//Loop to delete the closing crazy characters from each row, it is always the 7th character that needs to be removed.
		For(n = 1, n &amp;lt;= ncol(dtWAPFile), n++,
			colname = Column(n) &amp;lt;&amp;lt; get name;
			For( k = 1, k &amp;lt;= N Rows( dtWAPFile ), k++,
				RowVal = dtWAPFile:colname &amp;lt;&amp;lt; GetValues; //This gets a matrix
				NewRowVal = Left(RowVal,6); //This doesn't work with the matrix
				dtWAPFile:colname &amp;lt;&amp;lt; setvalues(NewRowVal);//This doesn't work...
				);&lt;/PRE&gt;&lt;PRE&gt;		For(n = 1, n &amp;lt;= ncol(dtWAPFile), n++,
			colname = Column(n) &amp;lt;&amp;lt; get name;
			For( k = 1, k &amp;lt;= N Rows( dtWAPFile ), k++,
				RowVal = dtWAPFile:colname[k]; //This gets the value for a row/column based on the loop
				NewRowVal = Left(RowVal,6); //This trims the value
				RowVal = setvalues(NewRowVal);//This doesn't work...can't seem to stuff it back in..
				);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2017 01:45:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-FOR-loop-to-check-values-in-cells-and-remove-the-7th/m-p/37964#M22228</guid>
      <dc:creator>MuttonChops</dc:creator>
      <dc:date>2017-04-11T01:45:42Z</dc:date>
    </item>
    <item>
      <title>Re: JSL FOR loop to check values in cells and remove the 7th character if there is one</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-FOR-loop-to-check-values-in-cells-and-remove-the-7th/m-p/37965#M22229</link>
      <description>&lt;P&gt;I think you are making it too hard. &amp;nbsp;This ode should work&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For( n = 1, n &amp;lt;= N Col( dtWAPFile ), n++,
	colname = Column( n ) &amp;lt;&amp;lt; get name;
	For( k = 1, k &amp;lt;= N Rows( dtWAPFile ), k++,
		Column( dtWAPFile, n )[k] = Left( Column( dtWAPFile, n )[k], 6 )
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Apr 2017 02:14:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-FOR-loop-to-check-values-in-cells-and-remove-the-7th/m-p/37965#M22229</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2017-04-11T02:14:21Z</dc:date>
    </item>
    <item>
      <title>Re: JSL FOR loop to check values in cells and remove the 7th character if there is one</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-FOR-loop-to-check-values-in-cells-and-remove-the-7th/m-p/37966#M22230</link>
      <description>&lt;P&gt;Getting an error (below) with it but I like hearing that I'm making it too hard. &amp;nbsp;Hopefully we are close.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;In the following script, error marked by /*###*/
For( n = 1, n &amp;lt;= N Col( dtWAPFile ), n++,
	colname = Column( n ) &amp;lt;&amp;lt; get name;
	For( k = 1, k &amp;lt;= N Rows( dtWAPFile ), k++,
		Column( dtWAPFile, n )[k] = Left( Column( dtWAPFile, n )[/*###*/k], 6 )
	);
)&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Apr 2017 02:29:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-FOR-loop-to-check-values-in-cells-and-remove-the-7th/m-p/37966#M22230</guid>
      <dc:creator>MuttonChops</dc:creator>
      <dc:date>2017-04-11T02:29:27Z</dc:date>
    </item>
    <item>
      <title>Re: JSL FOR loop to check values in cells and remove the 7th character if there is one</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-FOR-loop-to-check-values-in-cells-and-remove-the-7th/m-p/37967#M22231</link>
      <description>&lt;P&gt;If I step through the code and bypass the loop then it works.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2017 02:32:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-FOR-loop-to-check-values-in-cells-and-remove-the-7th/m-p/37967#M22231</guid>
      <dc:creator>MuttonChops</dc:creator>
      <dc:date>2017-04-11T02:32:39Z</dc:date>
    </item>
    <item>
      <title>Re: JSL FOR loop to check values in cells and remove the 7th character if there is one</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-FOR-loop-to-check-values-in-cells-and-remove-the-7th/m-p/37969#M22233</link>
      <description>&lt;P&gt;OK.....so I didn't test the code very well......or actually I really didn't test it.:-(&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Glad you got it figured out&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2017 03:02:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-FOR-loop-to-check-values-in-cells-and-remove-the-7th/m-p/37969#M22233</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2017-04-11T03:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: JSL FOR loop to check values in cells and remove the 7th character if there is one</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-FOR-loop-to-check-values-in-cells-and-remove-the-7th/m-p/38269#M22398</link>
      <description>&lt;P&gt;I didn't ever get it figured out but I found a work around. &amp;nbsp;For some reason I could step through the code and it would work but when I run the whole snippet it wouldn't....weird.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ultimately I had to remove the first FOR loop and not embed the second FOR loop inside the first FOR loop.&amp;nbsp;I'm hoping I had a simple mistake but I just couldn't get there and ran short on time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2017 14:47:15 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-FOR-loop-to-check-values-in-cells-and-remove-the-7th/m-p/38269#M22398</guid>
      <dc:creator>MuttonChops</dc:creator>
      <dc:date>2017-04-18T14:47:15Z</dc:date>
    </item>
    <item>
      <title>Re: JSL FOR loop to check values in cells and remove the 7th character if there is one</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-FOR-loop-to-check-values-in-cells-and-remove-the-7th/m-p/38271#M22400</link>
      <description>&lt;P&gt;Tweaking Jim's code a little:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;NamesDefaultToHere(1);

// Test Table
dt = New Table( "Test",
					Add Rows( 4 ),
					New Column( "Column 1",
						Character,
						"Nominal",
						Set Values( {"123456", "1234567", "12345678", "1234"} )
					),
					New Column( "Column 2",
						Character,
						"Nominal",
						Set Values( {"123456789", "123", "123456", "1234567"} )
					)
				);

// Truncate each cell to the leftmost six characters
Wait(3);
cols = dt &amp;lt;&amp;lt; getColumnNames("String");
for(c=1, c&amp;lt;=NItems(cols), c++,
	for(r=1, r&amp;lt;=NRow(dt), r++,
		Column(dt, cols[c])[r] = Left(Column(dt, cols[c])[r], 6);	
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Apr 2017 15:20:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-FOR-loop-to-check-values-in-cells-and-remove-the-7th/m-p/38271#M22400</guid>
      <dc:creator>ian_jmp</dc:creator>
      <dc:date>2017-04-18T15:20:13Z</dc:date>
    </item>
    <item>
      <title>Re: JSL FOR loop to check values in cells and remove the 7th character if there is one</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-FOR-loop-to-check-values-in-cells-and-remove-the-7th/m-p/38272#M22401</link>
      <description>Worked.  Thanks guys!  I love this forum btw, you guys are brilliant and make me look good at work :)&lt;/img&gt;</description>
      <pubDate>Tue, 18 Apr 2017 15:46:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-FOR-loop-to-check-values-in-cells-and-remove-the-7th/m-p/38272#M22401</guid>
      <dc:creator>MuttonChops</dc:creator>
      <dc:date>2017-04-18T15:46:46Z</dc:date>
    </item>
  </channel>
</rss>

