<?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 delete the entire column based on header and all rows with specific value in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JSL-delete-the-entire-column-based-on-header-and-all-rows-with/m-p/248181#M48712</link>
    <description>&lt;P&gt;Here is a script that will do what you want.&amp;nbsp; A couple of points about the script:&lt;/P&gt;
&lt;P&gt;1.&amp;nbsp; The Open() function has the "|" added as a delimiter in addition to the ",".&amp;nbsp; This was easily created by using the "Data Preview" when opening the .csv file.&amp;nbsp; It allowed for the selection of additional characters to be used as delimiters.&amp;nbsp; Then all that had to be done, is to open the file, and then go to the Source entry in the Tables Panel, and Edit it and copy out the Source Code that JMP created to open the file.&lt;/P&gt;
&lt;P&gt;2. The Deletion of the columns containing Apple had to be generalized, since in one column it was spelled Apple and in another column it was spelled apple.&lt;/P&gt;
&lt;P&gt;3. I really don't think you should be deleting a complete row, based upon finding an occurrence of -9999.&amp;nbsp; I really think you should be just setting the value -9999 to a missing value.&amp;nbsp; I included a piece of code that can handle your data that way, if you want.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to Here(1);
dt=Open(
	"file.csv",
	columns(
		New Column( "a", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "b", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "c", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "d", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "e", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "g", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "apple", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "orange", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "candy", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "pizza", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "Apple2_2", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "orange2", Numeric, "Continuous", Format( "Best", 12 ) )
	),
	Import Settings(
		End Of Line( CRLF, CR, LF ),
		End Of Field( Comma, Other( "|" ), CSV( 0 ) ),
		Strip Quotes( 1 ),
		Use Apostrophe as Quotation Mark( 0 ),
		Use Regional Settings( 0 ),
		Scan Whole File( 1 ),
		Treat empty columns as numeric( 0 ),
		CompressNumericColumns( 0 ),
		CompressCharacterColumns( 0 ),
		CompressAllowListCheck( 0 ),
		Labels( 1 ),
		Column Names Start( 1 ),
		Data Starts( 2 ),
		Lines To Read( "All" ),
		Year Rule( "20xx" )
	)
);

// Create a list to place columns to be deleted into
delList = {};

For( i = 1, i&amp;lt;= N Cols(dt), i++,
	If( Contains( Uppercase( as Column(  i ) &amp;lt;&amp;lt; get name ), "APPLE" ) &amp;gt; 0,
		insert into(delList, column(i)&amp;lt;&amp;lt;get name)
	)
);

dt &amp;lt;&amp;lt; delete columns( delList);

// Loop through the data and delete any rows that have
// the value -9999 in any of the columns
For( i = 1, i &amp;lt;= N Cols( dt ), i++,
	If( Column( dt, i ) &amp;lt;&amp;lt; get datatype == "Numeric",
		dt &amp;lt;&amp;lt; select where( As Column( dt, i ) == -9999 );
		If( N Rows(dt &amp;lt;&amp;lt; get selected rows) &amp;gt; 0,
			dt &amp;lt;&amp;lt; delete rows
		);
	)
);


/*// Substitute the code below for the last For Loop in the above 
// script, if what you want to do is to just change the -9999 
// values to missing values
For( i = 1, i &amp;lt;= N Cols( dt ), i++,
	If( Column( dt, i ) &amp;lt;&amp;lt; get datatype == "Numeric",
		dt &amp;lt;&amp;lt; select where( As Column( dt, i ) == -9999 );
		If( N Rows(dt &amp;lt;&amp;lt; get selected rows) &amp;gt; 0,
			column(dt,i)[dt &amp;lt;&amp;lt; get selected rows] = .;
		);
	)
);*/&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 19 Feb 2020 01:47:12 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2020-02-19T01:47:12Z</dc:date>
    <item>
      <title>JSL delete the entire column based on header and all rows with specific value</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-delete-the-entire-column-based-on-header-and-all-rows-with/m-p/248157#M48708</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to delete all columns that contain "apple" and delete all rows (regardless of columns) with specific value -9999. I had start the code to delete column but I'm not getting it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&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;&lt;CODE class=" language-jsl"&gt;dt = Open("file.csv"); 
//dt = Open( "$SAMPLE_DATA/Cities.jmp" );
col_list = dt &amp;lt;&amp;lt; get column names( string );
For( i = N Items( col_list ), i &amp;gt; 0, i--,
	If(Contains( col_list[i], "apple" ),
		Remove From( col_list, i ),
	)
);





//dt &amp;lt;&amp;lt; Select Where( );
//dt &amp;lt;&amp;lt; Delete Rows; 



dt &amp;lt;&amp;lt; save( "testOUT.txt" );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 18 Feb 2020 22:24:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-delete-the-entire-column-based-on-header-and-all-rows-with/m-p/248157#M48708</guid>
      <dc:creator>sam_t</dc:creator>
      <dc:date>2020-02-18T22:24:47Z</dc:date>
    </item>
    <item>
      <title>Re: JSL delete the entire column based on header and all rows with specific value</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-delete-the-entire-column-based-on-header-and-all-rows-with/m-p/248162#M48710</link>
      <description>My data value could have pipe data such as&lt;BR /&gt;&lt;BR /&gt;-9999|123,1,1,1,1,1,2,30,40,1,10,99&lt;BR /&gt;1,1,1,1,1,1,2,30,40,1,10,99&lt;BR /&gt;1,1,1,1,1,1,2,30,40,1,10,99&lt;BR /&gt;1,1,1,1|87,1,-9999,2,30,40,1,10,99</description>
      <pubDate>Tue, 18 Feb 2020 22:49:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-delete-the-entire-column-based-on-header-and-all-rows-with/m-p/248162#M48710</guid>
      <dc:creator>sam_t</dc:creator>
      <dc:date>2020-02-18T22:49:31Z</dc:date>
    </item>
    <item>
      <title>Re: JSL delete the entire column based on header and all rows with specific value</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-delete-the-entire-column-based-on-header-and-all-rows-with/m-p/248181#M48712</link>
      <description>&lt;P&gt;Here is a script that will do what you want.&amp;nbsp; A couple of points about the script:&lt;/P&gt;
&lt;P&gt;1.&amp;nbsp; The Open() function has the "|" added as a delimiter in addition to the ",".&amp;nbsp; This was easily created by using the "Data Preview" when opening the .csv file.&amp;nbsp; It allowed for the selection of additional characters to be used as delimiters.&amp;nbsp; Then all that had to be done, is to open the file, and then go to the Source entry in the Tables Panel, and Edit it and copy out the Source Code that JMP created to open the file.&lt;/P&gt;
&lt;P&gt;2. The Deletion of the columns containing Apple had to be generalized, since in one column it was spelled Apple and in another column it was spelled apple.&lt;/P&gt;
&lt;P&gt;3. I really don't think you should be deleting a complete row, based upon finding an occurrence of -9999.&amp;nbsp; I really think you should be just setting the value -9999 to a missing value.&amp;nbsp; I included a piece of code that can handle your data that way, if you want.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to Here(1);
dt=Open(
	"file.csv",
	columns(
		New Column( "a", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "b", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "c", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "d", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "e", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "g", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "apple", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "orange", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "candy", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "pizza", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "Apple2_2", Numeric, "Continuous", Format( "Best", 12 ) ),
		New Column( "orange2", Numeric, "Continuous", Format( "Best", 12 ) )
	),
	Import Settings(
		End Of Line( CRLF, CR, LF ),
		End Of Field( Comma, Other( "|" ), CSV( 0 ) ),
		Strip Quotes( 1 ),
		Use Apostrophe as Quotation Mark( 0 ),
		Use Regional Settings( 0 ),
		Scan Whole File( 1 ),
		Treat empty columns as numeric( 0 ),
		CompressNumericColumns( 0 ),
		CompressCharacterColumns( 0 ),
		CompressAllowListCheck( 0 ),
		Labels( 1 ),
		Column Names Start( 1 ),
		Data Starts( 2 ),
		Lines To Read( "All" ),
		Year Rule( "20xx" )
	)
);

// Create a list to place columns to be deleted into
delList = {};

For( i = 1, i&amp;lt;= N Cols(dt), i++,
	If( Contains( Uppercase( as Column(  i ) &amp;lt;&amp;lt; get name ), "APPLE" ) &amp;gt; 0,
		insert into(delList, column(i)&amp;lt;&amp;lt;get name)
	)
);

dt &amp;lt;&amp;lt; delete columns( delList);

// Loop through the data and delete any rows that have
// the value -9999 in any of the columns
For( i = 1, i &amp;lt;= N Cols( dt ), i++,
	If( Column( dt, i ) &amp;lt;&amp;lt; get datatype == "Numeric",
		dt &amp;lt;&amp;lt; select where( As Column( dt, i ) == -9999 );
		If( N Rows(dt &amp;lt;&amp;lt; get selected rows) &amp;gt; 0,
			dt &amp;lt;&amp;lt; delete rows
		);
	)
);


/*// Substitute the code below for the last For Loop in the above 
// script, if what you want to do is to just change the -9999 
// values to missing values
For( i = 1, i &amp;lt;= N Cols( dt ), i++,
	If( Column( dt, i ) &amp;lt;&amp;lt; get datatype == "Numeric",
		dt &amp;lt;&amp;lt; select where( As Column( dt, i ) == -9999 );
		If( N Rows(dt &amp;lt;&amp;lt; get selected rows) &amp;gt; 0,
			column(dt,i)[dt &amp;lt;&amp;lt; get selected rows] = .;
		);
	)
);*/&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Feb 2020 01:47:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-delete-the-entire-column-based-on-header-and-all-rows-with/m-p/248181#M48712</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-02-19T01:47:12Z</dc:date>
    </item>
    <item>
      <title>Re: JSL delete the entire column based on header and all rows with specific value</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-delete-the-entire-column-based-on-header-and-all-rows-with/m-p/248189#M48715</link>
      <description>&lt;P&gt;Jim,&lt;/P&gt;&lt;P&gt;The code works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I use the "|" pipe. It will create extra column(s).&lt;/P&gt;&lt;P&gt;I do not want any extra my column header in this case, it will be "12" columns total.&lt;/P&gt;&lt;P&gt;But in each column, I can have several pipe data. I only care the first value and ignore the rest.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;"99|23|abc|x", I only care for "99" and ignore the rest.&lt;/P&gt;&lt;P&gt;"-9999|123", I only care for "-9999" and that row will get delete it later.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;1	1	1	1	1	1	2	30	40	1	10	99
1	1	1	1	1	1	2	30	40	1	10	99
1	-9999|999|231	1	1	1	1	2	30	40	1	10	99
1	1	1	1	1	1	2	30	40	1	10	99
1	1|xyz|abc	1	1	1	1	2	30	40	1	10	99
1	1	1	1	1	1	2	30	40	1	10	99
1	1	1	1	1	1	2	30	40	1	10	99
1	1	1	1	1	1	2	30	40	1	10	99
1	1	1	1	1	1	-9999	30	40	1	10	99
1	1	1	1	1	1	2	30	40	1	10	99
1	1	1	1	1	1	2	30	40	1	10	99
1	1	1	1	1	1	2	30	40	1	10	99
1	99|23|abc|x	1	1	1	1	2	30	40	1	10	99
1	1	1	1	1	1	2	30	40	1	10	99
-9999|123	1	1	1	1	1	2	30	40	1	10	99
1	1	1	1	1	1	2	30	40	1	10	99
1	1	1	1	1	1	2	30	40	1	10	99
1	1	1	1|87	1	-9999	2	30	40	1	10	99&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Feb 2020 02:35:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-delete-the-entire-column-based-on-header-and-all-rows-with/m-p/248189#M48715</guid>
      <dc:creator>sam_t</dc:creator>
      <dc:date>2020-02-19T02:35:36Z</dc:date>
    </item>
    <item>
      <title>Re: JSL delete the entire column based on header and all rows with specific value</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-delete-the-entire-column-based-on-header-and-all-rows-with/m-p/248196#M48717</link>
      <description>&lt;P&gt;It is a very simple change to the script.&amp;nbsp; All of the special options for the inputting of the data, can be eliminated.&amp;nbsp; The Open() function will just use the defaults.&lt;/P&gt;
&lt;P&gt;Secondly, all that has to be done to the row deletions, is to search for a string value of "-9999" when the input column is determined to be character in nature.&lt;/P&gt;
&lt;DIV&gt;&lt;FONT face="Menlo,Monaco,Consolas,&amp;quot;Courier New&amp;quot;,monospace" size="2" style="background-color: #f5f5f5;"&gt;names default to Here(1);&lt;BR /&gt;dt=Open(&lt;BR /&gt;&amp;nbsp;"file (3).csv");&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Menlo,Monaco,Consolas,&amp;quot;Courier New&amp;quot;,monospace" size="2" style="background-color: #f5f5f5;"&gt;// Create a list to place columns to be deleted into&lt;BR /&gt;delList = {};&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Menlo,Monaco,Consolas,&amp;quot;Courier New&amp;quot;,monospace" size="2" style="background-color: #f5f5f5;"&gt;For( i = 1, i&amp;lt;= N Cols(dt), i++,&lt;BR /&gt;&amp;nbsp;If( Contains( Uppercase( as Column(&amp;nbsp; i ) &amp;lt;&amp;lt; get name ), "APPLE" ) &amp;gt; 0,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;insert into(delList, column(i)&amp;lt;&amp;lt;get name)&lt;BR /&gt;&amp;nbsp;)&lt;BR /&gt;);&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Menlo,Monaco,Consolas,&amp;quot;Courier New&amp;quot;,monospace" size="2" style="background-color: #f5f5f5;"&gt;dt &amp;lt;&amp;lt; delete columns( delList);&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="Menlo,Monaco,Consolas,&amp;quot;Courier New&amp;quot;,monospace" size="2" style="background-color: #f5f5f5;"&gt;// Loop through the data and delete any rows that have&lt;BR /&gt;// the value -9999 in any of the columns&lt;BR /&gt;For( i = 1, i &amp;lt;= N Cols( dt ), i++,&lt;BR /&gt;&amp;nbsp;If( Column( dt, i ) &amp;lt;&amp;lt; get datatype == "Numeric",&lt;BR /&gt;&amp;nbsp;&amp;nbsp;dt &amp;lt;&amp;lt; select where( As Column( dt, i ) == -9999 ),&lt;BR /&gt;&amp;nbsp;&amp;nbsp;dt &amp;lt;&amp;lt; select where( Contains( As Column( dt, i ), "-9999" ) == 1 |&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Contains( As Column( dt, i ), "99" ) == 1&lt;BR /&gt;&amp;nbsp;&amp;nbsp;)&lt;BR /&gt;&amp;nbsp;);&lt;BR /&gt;&amp;nbsp;If( N Rows( dt &amp;lt;&amp;lt; get selected rows ) &amp;gt; 0,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;dt &amp;lt;&amp;lt; delete rows&lt;BR /&gt;&amp;nbsp;);&lt;BR /&gt;);&lt;BR /&gt;&lt;/FONT&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 19 Feb 2020 04:32:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-delete-the-entire-column-based-on-header-and-all-rows-with/m-p/248196#M48717</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-02-19T04:32:05Z</dc:date>
    </item>
  </channel>
</rss>

