BookmarkSubscribe
Choose Language Hide Translation Bar
uday_guntupalli
Community Trekker

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
0 Kudos
1 ACCEPTED SOLUTION

Accepted Solutions
ms
Super User ms
Super User

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 ""

0 Kudos
4 REPLIES 4
uday_guntupalli
Community Trekker

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
0 Kudos
ms
Super User ms
Super User

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 );

0 Kudos
uday_guntupalli
Community Trekker

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
0 Kudos
ms
Super User ms
Super User

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 ""

0 Kudos