Subscribe Bookmark RSS Feed

how can I extract txt values

gow

Community Trekker

Joined:

May 8, 2012

Attached is sample of data in first 3 cells of the column "information" .

I need keep "first name" and "start date" if present and delete remaining txt in that cell of the column.

cell 1 = Unknown Pic, CV, start date, stop date, first name, last name

cell 2 = start date, stop date, Unknown Pic, first name, risk data

cell 3 = Unknown Pic, risk data, sart date

I have tried munger, left and right commands to remove un wanted text. will it be possible to use "Remove" command to remove specific text such as " Unknown Pic"

Any guidance will be Helpful

Thanks

Gow

2 REPLIES
pmroz

Super User

Joined:

Jun 23, 2011

Linlin I think by attached Gow meant "shown below".  Anyway this code might help:

// I need to keep "first name" and "start date" if present and delete remaining txt in that cell of the column.

cell = {};

cell[1] = "Unknown Pic, CV, start date, stop date, first name, last name";

cell[2] = "start date, stop date, Unknown Pic, first name, risk data";

cell[3] = "Unknown Pic, risk data, start date";

for (i = 1, i <= nitems(cell), i++,

      new_cell = "";

      if (contains(cell[i], "first name"),

            new_cell = "first name";

      );

      if (contains(cell[i], "start date"),

            if (new_cell == "",

                  new_cell = "start date";

                  ,

                  new_cell = new_cell || ", " || "start date";

            );

      );

     

      cell[i] = new_cell;    

);

write(cell);

Gow: if "first name" and "start date" are meant to be variables then you might try using the WORDS function to parse each string.

gow

Community Trekker

Joined:

May 8, 2012

Thanks, this helped me to figure out the issue.