Page 1 of 1

How to remove \n from the text field

Posted: June 28th, 2024, 4:32 pm
by khurshid.arshad
Dear Team;

I want to remove "\n" from the text field through batch editing. The data file is in csdb format.
Please advice on how to resolve this issue.

thanks.
a.

Re: How to remove \n from the text field

Posted: July 1st, 2024, 10:32 am
by Gregory Martin
If you're using CSPro 8.0+, you'd simply do:
STRING_FIELD = replace(STRING_FIELD, "\n", "");

Re: How to remove \n from the text field

Posted: July 1st, 2024, 11:56 am
by khurshid.arshad
Dear Gregory;

I am using this in a batch file. When i run the application, it removes all informtion from the fields starting from the newline character ("\n") onward.

I am using cspro 7.7.

PROC RECOM_PSYCHOLOGIST1


Preproc
mystring =RECOM_PSYCHOLOGIST1;

mystring = replace(mystring, '\n', ' ');


RECOM_PSYCHOLOGIST1=mystring;
Thanks.
a.

Re: How to remove \n from the text field

Posted: July 1st, 2024, 12:04 pm
by khurshid.arshad
One more thing:
After getting the data in csdb format using 7.7, I am using 8.0.1 to export the data from csdb to SPSS without using the replace function. In this case the new line character("\n") automatically replaced by a question mark(?), and all the data is exported without any issue.

thanks.
a.

Re: How to remove \n from the text field

Posted: July 1st, 2024, 5:17 pm
by Gregory Martin
Escape sequences like \n are only supported using the logic version introduced in CSPro 8.0. See more here:

https://www.csprousers.org/help/CSPro/s ... erals.html

So if you're trying to replace "\n" using the old logic version, that string is not actually a newline character, but is instead a backslash character and n ("\\n" in the new logic version).

Basically if you want to manipulate any string with newlines, you'll have to use the new logic version.

You can read more about newlines here: https://www.csprousers.org/help/CSPro/n ... dling.html

Re: How to remove \n from the text field

Posted: July 1st, 2024, 5:40 pm
by khurshid.arshad
Thank you.
A.