cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
uday_guntupalli
Level VIII

How to remove blank spaces from a List in JSL ?

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 (Alumni) ms
Super User (Alumni)

Re: How to remove blank spaces from a List in JSL ?

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

View solution in original post

4 REPLIES 4
uday_guntupalli
Level VIII

Re: How to remove blank spaces from a List in JSL ?

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 (Alumni) ms
Super User (Alumni)

Re: How to remove blank spaces from a List in JSL ?

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
Level VIII

Re: How to remove blank spaces from a List in JSL ?

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 (Alumni) ms
Super User (Alumni)

Re: How to remove blank spaces from a List in JSL ?

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