Is there a simple way to remove a string from every column in a row in a DT

After a lot of scraping of values into String vars I have a DT with about 200 columns. Often I see NA or just a dash returned in one or more of the columns in a row. I’d like to replace the “NA” and “-” values with null value before I write out the row to a file.
Is there a simple way to iterate through every column in a row and replace/remove values that are “NA” or “-”?

Hy @DaveF ,

You can do a ‘for each row’ activity combined with a ‘for each’ to itenarete through all the items in each column.
I will prepare a sample workflow for you



Find attached a sample workflow. (29.2 KB)

If it is what you need please like my posts and mark answer as solution, it helps me :slight_smile:
Any questions please let me now


1 Like

have a look on following demo, showcasing removing, trimming values:TrimRemove_AllCellsAllRows.xaml (9.0 KB)

with a change of the replace arguments the NA, - can be changed with the approach. As replace is chainable we can work like this. yourString.replace(“NA” …replace(“-”…

also have a look here:

I get the feeling that this is close, but I’m no coder so it’s going over my head a little. Also, I have some negative values I would want to keep as negatives (sorry, forgot to mention that before), so something that replaces any instance in a string is overkill for me.

That does indeed loop through every column in every row. Where I want to put this purge s/tidy up step will be just before I write out the latest row of scraped data to file. I could try to modify what you have to just loop through the latest column, but then I’m not sure how to replace the “NA” and “-” and retain negative values and words with “na” in them intact.

Hy @DaveF,

To complete what you want:
Assign to a string the row(column).toString


It will do the trick.

Please like my my posts and mark my answer as a solution, it helps me :slight_smile:
Any more questions please let me know


1 Like

I’ve obviously asked the question incorrectly. I’ll try again in a new thread. Sorry