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

The 4th edition of the Campaign Community Lens newsletter is out now!
SOLVED

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

Avatar

Level 2

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.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

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

The ultimate experience is back.

Join us in Vegas to build skills, learn from the world's top brands, and be inspired.

Register Now