Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

File extraction with headers only, no data

Avatar

Level 1

Is it possible to extract a blank file with headers only using the File Extraction activity?

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Hi all,

you could also use the File class (https://experienceleague.adobe.com/developer/campaign-api/api/c-File.html?hl=file) to achieve this:

var f = new File("/path/to/output/file.csv");
f.open("a"); // opens file in "append" mode
f.writeln("Header 1;Header 2; Header 3");
f.close();

Cheers, Tobias

View solution in original post

2 Replies

Avatar

Community Advisor

Hi @rebeccat1844660 - I don't think the File Extraction activity will output a header-only CSV file. You have to have at least one data row for it to output the header. Strangely it will create a blank file if there are no rows.

I would use a simple JS execCommand activity to create your header-only CSV e.g.

 

execCommand("echo header_1,header_2,header_3 > /sftp/your/path/goes/here/output_file.csv");

Cheers

 

Darren

Avatar

Correct answer by
Employee Advisor

Hi all,

you could also use the File class (https://experienceleague.adobe.com/developer/campaign-api/api/c-File.html?hl=file) to achieve this:

var f = new File("/path/to/output/file.csv");
f.open("a"); // opens file in "append" mode
f.writeln("Header 1;Header 2; Header 3");
f.close();

Cheers, Tobias