Export csv to SFTP with headers only | Adobe Higher Education
Skip to main content
Level 3
April 22, 2022
Resuelto

Export csv to SFTP with headers only

  • April 22, 2022
  • 4 respuestas
  • 3199 visualizaciones

I have created a workflow where I'm extracting data and exporting the required column in csv format to SFTP location. But in case there are 0 records I have to export blank csv file to SFTP with headers only. 

 

Can you please guide how this can be achieved. Currently it creates blank file without headers.

 

Thanks in advance.

Este tema ha sido cerrado para respuestas.
Mejor respuesta de parmeshwarr3905

Achieved using Javascript activity.

 

var f = new File(vars.filename)
f.open("a"); //append mode
f.writeln("column_name1,column_name2,column_name3");
f.close()

 

 

 

4 respuestas

Marcel_Szimonisz
Community Advisor
Community Advisor
April 23, 2022

Hello @parmeshwarr3905 ,

you can create file with and write headers in to it when there is no records from JS activity. Or you can create one dummy file with headers save it to the server file storage and send that instead when there is no data.

 

Marcel

Level 3
April 25, 2022

Hi @marcel_szimonisz 

 

I have used test activity to check if there are zero records then next is JS activity where i'm writing a code to create a file with headers but i'm getting an error "Access to file '<path>' is forbidden "

 

 

 

 

please let me know the error reason or alternate way.

I can create a dummy file as you suggested but if someone deletes that by mistake it could be a problem.

Adobe Employee
April 28, 2022

HI there,

Why use a Java Script when the Data Extract activity is already proposing the capability

If there is no record, a file with just the header will be created, no need to JavaScript.

Let me know if it solves your topic,

Thanks
Denis

 

Level 3
April 28, 2022

@costa_n11  I had that option selected but it is creating a file without headers. correct me if I'm missing any other settings

 

Thanks

Adobe Employee
April 28, 2022

Hi, this is new then because it has worked in the past for sure....sorry to hear it doesn't anymore... back to the JS which isn't great really....

Thanks

Denis

Kishore_Padamata
Adobe Employee
Adobe Employee
May 20, 2022

Hello @parmeshwarr3905 
Please see below setup
Test activity -> To check for 0 Records
Query activity -> To fetch 1 record from any schema. Maybe use a Primary Key filter from nms:recipient or any other schema.
Data extraction activity -> 
- uncheck Use first line as column header
- Data formatting step, provide the number of header columns with
Create new of Type Fixed String

Provide your header string in the edit box without any single/double quotes

Hope this helps!

parmeshwarr3905AutorRespuesta
Level 3
July 20, 2022

Achieved using Javascript activity.

 

var f = new File(vars.filename)
f.open("a"); //append mode
f.writeln("column_name1,column_name2,column_name3");
f.close()