Jump to content

trailing spaces in data


rpaterick

Recommended Posts

When importing a .csv file and the client has trailing spaces in the data that should not be there. Is there a specific way to import the .csv file or rules to apply?

I tried the Users Manual and couldn't figure-out how to eliminate trailing spaces.

 

Thanks,

Ryan:o

Link to comment
Share on other sites

Ryan,

 

There are a number of commands that will let you remove trailing spaces and/or leading spaces in data fields. They are called "trim" commands.

 

LTrim(Field"yourfield") will remove leading spaces (extra spaces to the left or in the beginning of the data field you specify).

 

RTrim(Field"yourfield") will remove trailing spaces (extra spaces to the right or after the data field you specify).

 

Trim(Field"yourfield") will remove both trailing and leading spaces in your data field.

 

You can even use "regular expressions" to remove the possibility of extra spaces within the data field string itself.

 

Good Luck.

Link to comment
Share on other sites

You can even use "regular expressions" to remove the possibility of extra spaces within the data field string itself.

 

Good Luck.

 

DSweet, thanks for the suggestions. Because the data is Upper-Case, I applied the "Proper-Case" to the field and that took care of the trailing spaces also, weird.:cool:

 

Thanks,

Ryan

Link to comment
Share on other sites

Ryan,

There are a number of commands that will let you remove trailing spaces and/or leading spaces in data fields. They are called "trim" commands.

 

DSweet, I'm putting a comma after the Field City and I'm getting one blank space added. I have Proper Casing applied to the field but how do I apply the RTrim code properly to it?

 

ex: Munro , BUENOS AIRES 1605ank

extra space after the word Munro.

 

Code below of the "City" column.

 

Thanks,

Ryan

 

Var1="City";
CaseSelection="propercase";



if(CaseSelection == "allcaps")
return ToUpper(Field(Var1));

if(CaseSelection == "smallcaps")
return "<smallcap>" + Field(Var1) + "</smallcap>";

if(CaseSelection == "propercase")
return ToTitleCase(Field(Var1));

if(CaseSelection == "lowercase")
return ToLower(Field(Var1));

Link to comment
Share on other sites

Ryan,

 

Functions can be nested within one another, but I normally put any trim function as the outside function like so...

 

if (CaseSelection == "propercase")

....return RTrim(ToTitleCase(Field(Var1)));

 

This way I am sure that whether or not the inner function(s) add spaces to the field, I know that any extra leading or trailing spaces will be removed before the rule returns its value.

 

Good luck.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...