Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I am using Fake to automate some web tasks.

I have a CSV file on disk that contains rows of data which I'd like to use to fill out forms in my Fake Workflow.

How can I iterate thru the rows in the CSV file and access the values found in each column in my Fake Workflow?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

The best approach is to use the Repeat With Action with the lines in file option selected. This allows you to read the CVS file on disk and iterate thru the rows as Fake Variables. You can then access these Fake Variables in other Actions which can fill out the web form (or whatever you need).

enter image description here

As seen in the screenshot above, I'm using a Do JavaScript action to initially fetch the current line Variable and then split it into an array of comma separated values.

var line = fake.get('line');

Then I use Fake's JavaScript API to set individual variables for each column:

var row = line.split(',');
fake.set('first', row[0]);
fake.set('last', row[1]);

Then use other Fake Actions to work with the data you've fetched. In this case, I'll fill out a simple web form using the Set Value of HTML Element Action. In this Action's text fields you can access Fake Variables with this special syntax:

${first}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.