How to store CSV data of Data loding (file) in Javascript variable? | Community
Skip to main content
Level 2
Jan 19, 2021 6:20 AM UTC
Solved

How to store CSV data of Data loding (file) in Javascript variable?

Hello, I'm Super Beginner.

 

How to store CSV data of Data loding (file) in Javascript variable?

Or can read the CSV file directly with JavaScript?

 

Thank you.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
ParthaSarathy
ParthaSarathyAccepted solution
New Participant
Jan 19, 2021 9:38 AM UTC

Hi @uz2020 ,

Lets say your Csv file contains 2 columns 'name' and 'email'. And internal name of your data loading (file) activity as 'fileImport'.

Next to your data loading activity, place a javaScript activity and try the below coding,

 

var query = xtk.queryDef.create(
<queryDef schema="temp:fileImport" operation="select">
<select>
<node expr="name"/>
<node expr="email"/>
</select>
</queryDef>
);
var record = query.ExecuteQuery();
for each (var variable in record) {
instance.vars.name = variable.name;
instance.vars.email= variable.email;
logInfo("Name is : "+instance.vars.name);
logInfo("Email is : "+instance.vars.email);
}
 
Regards,
ParthaSarathy S
 ~  ParthaSarathy S~  Click here to join ADOBE CAMPAIGN USER GROUP for Quarterly In-person | Hybrid | Virtual Meetups

3 replies

ParthaSarathy
ParthaSarathyAccepted solution
New Participant
Jan 19, 2021 9:38 AM UTC

Hi @uz2020 ,

Lets say your Csv file contains 2 columns 'name' and 'email'. And internal name of your data loading (file) activity as 'fileImport'.

Next to your data loading activity, place a javaScript activity and try the below coding,

 

var query = xtk.queryDef.create(
<queryDef schema="temp:fileImport" operation="select">
<select>
<node expr="name"/>
<node expr="email"/>
</select>
</queryDef>
);
var record = query.ExecuteQuery();
for each (var variable in record) {
instance.vars.name = variable.name;
instance.vars.email= variable.email;
logInfo("Name is : "+instance.vars.name);
logInfo("Email is : "+instance.vars.email);
}
 
Regards,
ParthaSarathy S
Translate
 ~  ParthaSarathy S~  Click here to join ADOBE CAMPAIGN USER GROUP for Quarterly In-person | Hybrid | Virtual Meetups
uz2020Author
Level 2
Jan 20, 2021 1:23 AM UTC
@parthasarathy I was able to do it. Thank you!
Translate