Sun Nov 17, 2019 9:22 am
Login Register Lost Password? Contact Us


Writing a Null character to a flat file

Comments and questions related to the Enterprise Control Language

Thu Oct 31, 2019 4:19 pm Change Time Zone

NULL.PNG
Example of file with null character
(59.63 KiB) Not downloaded yet
I am producing a tab delimited file but in some fields instead of an empty string I need to write out a null character. I am writing a process to replace an existing file from another system. Attached is a picture of the existing file shown in Notepad++ with all symbols shown

How do I do this?
jtaylor178
 
Posts: 4
Joined: Mon Oct 07, 2019 5:57 pm

Thu Oct 31, 2019 5:53 pm Change Time Zone

jtaylor178,

You can do it just like this:
Code: Select all
Nul := '\000';
ds := DATASET([{'ABC',Nul,'DEF'}],{STRING3 F1,STRING3 F2,STRING3 F3});
OUTPUT(ds,,'~RTTEST::CSV::NullTest',CSV(SEPARATOR('\t')));
The Nul definition uses the octal constant form for string constants to specify the character is an ASCII zero.

HTH,

Richard
rtaylor
Community Advisory Board Member
Community Advisory Board Member
 
Posts: 1485
Joined: Wed Oct 26, 2011 7:40 pm

Thu Oct 31, 2019 6:42 pm Change Time Zone

darn, simple. I should have thought of that. thanks
jtaylor178
 
Posts: 4
Joined: Mon Oct 07, 2019 5:57 pm


Return to ECL

Who is online

Users browsing this forum: No registered users and 1 guest

cron