Subscribe Bookmark RSS Feed

How to remove blank spaces from a List in JSL ?

uday_guntupalli

Community Trekker

Joined:

Sep 15, 2014

Hello all ,

        I am new to JMP Scripting . I was working on something and was trying to delete empty spaces from a list in JMP . I have done the following in order to do that :

for(i=1,i<nrows(dt),i++,

  if(SampleList(i)== "",

    //then

  Remove From(SampleList,i,1);

   //else

     ,

     ShowSampleList);

   );

    );

Best
Uday
1 ACCEPTED SOLUTION

Accepted Solutions
ms

Super User

Joined:

Jun 23, 2011

Solution

O I misunderstood. Looks like you're not after "blank spaces" but empty values. Change " " into ""

4 REPLIES
uday_guntupalli

Community Trekker

Joined:

Sep 15, 2014

Just to clarify , I used Show(SampleList). I was trying to edit it when the post went through. I am not receiving an error, but there are no changes being made  to the list either despite the fact that it has empty spaces .

Regards

Uday

Best
Uday
ms

Super User

Joined:

Jun 23, 2011

In JSL, square brackets are used for list subscripts. Also, when using Remove from() it's usually better to loop from the end of the list (or any consecutive spaces will not be removed as intended).

SampleList = {" ", " ", "B", "C", " ", "A", "B", "C", " "};

For( i = N Items( samplelist ), i > 0, i--,

  If( SampleList[i] == " ",

    //then

  Remove From( SampleList, i, 1 );

   //else

  ,

  Show( SampleList )

  )

);

Show( SampleList );

uday_guntupalli

Community Trekker

Joined:

Sep 15, 2014

Hello MS , 

          for(i=N items(IrradianceSensorIds),i>0,i--,

                 if(IrradianceSensorIds == " ",

                      Remove From(IrradianceSensorIds,i,1);

                      ,

                      Show(IrradianceSensorIds)

                  )

              );

          Show(IrradianceSensorIds);

IrradianceSensorIds = {"SH01 Radiation", "SH02 Radiation", "SH03 Radiation", "SH04 Radiation", "SH05 Radiation", "", "", ""};

IrradianceSensorIds = {"SH01 Radiation", "SH02 Radiation", "SH03 Radiation", "SH04 Radiation", "SH05 Radiation", "", "", ""};

IrradianceSensorIds = {"SH01 Radiation", "SH02 Radiation", "SH03 Radiation", "SH04 Radiation", "SH05 Radiation", "", "", ""};

IrradianceSensorIds = {"SH01 Radiation", "SH02 Radiation", "SH03 Radiation", "SH04 Radiation", "SH05 Radiation", "", "", ""};

IrradianceSensorIds = {"SH01 Radiation", "SH02 Radiation", "SH03 Radiation", "SH04 Radiation", "SH05 Radiation", "", "", ""};

IrradianceSensorIds = {"SH01 Radiation", "SH02 Radiation", "SH03 Radiation", "SH04 Radiation", "SH05 Radiation", "", "", ""};

IrradianceSensorIds = {"SH01 Radiation", "SH02 Radiation", "SH03 Radiation", "SH04 Radiation", "SH05 Radiation", "", "", ""};

IrradianceSensorIds = {"SH01 Radiation", "SH02 Radiation", "SH03 Radiation", "SH04 Radiation", "SH05 Radiation", "", "", ""};

IrradianceSensorIds = {"SH01 Radiation", "SH02 Radiation", "SH03 Radiation", "SH04 Radiation", "SH05 Radiation", "", "", ""};

There is no change in the result even if I use the square brackets . Here is the actual snippet and the result from the Log

Best
Uday
ms

Super User

Joined:

Jun 23, 2011

Solution

O I misunderstood. Looks like you're not after "blank spaces" but empty values. Change " " into ""