Writing to a CSV file with a trigger


This example demonstrates how to export data from MarketFeeder Pro to a text file using the "write to file" trigger action.

Please bear in mind that exporting proprietary market data, such as prices and volumes, for commercial purposes violates the Terms and Conditions of the BetFair Historical Data Licence!

MarketFeeder Pro has a built-in function of writing to a file, which you can use to export any piece of data, an expression, a trigger variable of a combination of thereof to a text file of your choice.

In this example, we will be writing down BetFair Starting Prices (SP) for selections within the specified price range. We will then learn to open that file in Excel to view and analyse the results.


Click here to download the trigger file.

There are just two constants in this file, and they are needed to filter out selections by their SP. The constants are used for the sake of example only, just to reduce the size of the end file.

min_sp : Minimum SP of qualifyng selections;

max_sp : Maximum SP of qualifying selections.

In Action

So let's take a look at the triggers:

Triggers writing to a file

Here we have two triggers:

1. writing headers at the beginning of the file

You can run this trigger to make your data look like a table with headers. At the beginning of your session, it will write the headers "MarketName", "SelectionName" and "SP" into the file at the provided path (in this case, d:\sp_prices.csv). Note that it has the option "Rewrite existing contents" ticked, i.e. it first empties the contents of the file (if there were any). You can disable this trigger if you do not need headers or if you do not want the file to be rewritten each time you restart the triggers.

2. writing to a file

Here the trigger actually writes the name of the market, the name of the qualifying selection and its SP to the specified file. The values are separated with commas, the text variables (market_name and sel_name) are enclosed in double quotes to keep spaces inside them.

If you run the triggers against a few markets, you will get something similar to this:

CSV file with selections' SP

Importing to Excel

Open Excel and switch to the Data tab. Go through the steps illustrated below, each time pressing "Next" until you get to the last screen.

Step 1:

Import data from text

Step 2:

Text import wizard

Step 3:

Text import wizard

Step 4:

Text import wizard

Step 5:

Data from the text file in Excel

If you have not heard of BetFair yet or do not have an account, register today and get £20 free. Use the link below:
© 2005-2017 WellDone Creative Software. All rights reserved. Terms and conditions.
BetFair® and the BetFair Logo are registered trade marks of The Sporting Exchange Limited. Gamble responsibly.