File extraction with headers only, no data | Community
Skip to main content
rebeccat1844660
New Participant
January 31, 2022
Solved

File extraction with headers only, no data

  • January 31, 2022
  • 2 replies
  • 1194 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Tobias_Lohmann

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

2 replies

Tobias_Lohmann
Tobias_LohmannAccepted solution
Employee
February 1, 2022

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

Darren_Bowers
New Participant
February 1, 2022

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