Subscribe Bookmark RSS Feed

Question on JSL filling row blanks within a column

Sully

New Contributor

Joined:

Aug 24, 2017

Hello All,

I am relatively new to JSL. I have a character column labeled State, within the column are the initals of the various US states. However, within this column there are blanks, I want to be able to created a JSL that will allow me to replace the blanks with the word "International". I have been looking all over and have been unable to find a coding that would allow me to replace the blanks within my State column with International.

 

Any advice would be appreciated!!  

1 ACCEPTED SOLUTION

Accepted Solutions
pmroz

Super User

Joined:

Jun 23, 2011

Solution
dt = New Table( "Untitled 24", Add Rows( 6 ),
	New Column( "State", Character, "Nominal",
		Set Values( {"PA", "DE", "NJ", "", "", "VA"} )
	)
);

blank_rows = dt << get rows where(as column(dt, "State") == "");

if (nrows(blank_rows) > 0,
	column(dt, "State")[blank_rows] = "International";
);
3 REPLIES
Sully

New Contributor

Joined:

Aug 24, 2017

The data table is being opened from a text file. I am not querying to get the data.

pmroz

Super User

Joined:

Jun 23, 2011

Solution
dt = New Table( "Untitled 24", Add Rows( 6 ),
	New Column( "State", Character, "Nominal",
		Set Values( {"PA", "DE", "NJ", "", "", "VA"} )
	)
);

blank_rows = dt << get rows where(as column(dt, "State") == "");

if (nrows(blank_rows) > 0,
	column(dt, "State")[blank_rows] = "International";
);
Sully

New Contributor

Joined:

Aug 24, 2017

That worked perfectly! Thank you!