How to create a CSV integration using Named Data Sources
Overview
CSV integrations are one of the simplest and most useful integrations. Unlike other types of integrations, this integration takes a CSV database contained within a trigger file and breaks it apart into variables which can be passed to a label file. Make sure to use the version dropdown at the top as UI may be different between BarTender versions.
If you are looking for similar integrations, see these other helpful tutorials:
- Print Document Using Print Command Script (Video - 9:40) - an Integration which sets the printer and label information in the script header and contains a CSV database
- How to create a basic CSV integration - a CSV integration which uses a database override to send data to a label.
- Building a database integration (Video - 33:42) - an integration that operates very similarly to this type of CSV integration and uses Named Data Sources on the label.
Applicable to
BarTender 2022 and later
Information
Setting up the label
This type of label does not use a database but instead uses Named Data Sources to handle all its data. This will go over the basics of how to set up this label. For more information, see Named Data Sources in the help file.
- Create a new label.
- Create a text object on the label design area.
- Right click on the label and select properties.
- Select the data source from the list. It'll say "Sample Text."
- Click the box next to the Name field.
- In the dialog, type a unique name and click OK. For this example, use ProductName.
- Ensure the Type is set to Embedded Data.
- When creating more text objects, the Named Data Source dialog will look different. When you click the box next to the Name field, bubble in the first option to create a new name. For example, use ProductType.
- Once you have created as many Named Data Sources as you wish, save the label.
Creating the integration
For your integration, you will need a trigger file. The CSV field names do not need to match your Named Data Source names, as you'll be matching the fields to the Named Data Sources here in the integration. These CSV field names will become a variable in your integration automatically. Make sure that your field names do not use spaces.
This example also includes printer information. Modify the label name and printer name before testing in your own integration. Here is the example:
Name,Food,ID,btw,printer
Seagull Seed Rings,bird food,1236468,Test.btw,Zebra 105
- Open Integration Builder and select "Create New Integration."
- On the new integration dialog, select File Integration and click OK.
- First, set up how the integration will detect files by setting the scan folder. This is where your trigger files will be dropped and the integration will pick them up. For my example, I used a folder on the C drive. Avoid locations such as My Documents or the Desktop as it requires extra permissions to reach those locations.
- Click the dropdown next to Location and choose "Computer/Network"
- Type the folder name or use the Browse button to locate it.
- Change the File Pattern to match your file. I am using the default of .dat but you can use .txt, .csv, or any type you would like.
- Scroll down to the bottom of this section. If you are using a *.txt file pattern, change the "After Detection" options to a different file extension so the integration will not repeatedly pick up the same file again and again.
- On the lefthand menu, click the + button next to Actions.
- In the dialog, click the Transform category then select "Transform Text to Record Set" then click OK.
- Click the "Database Connection Setup" button and proceed through the wizard steps in order to connect to a CSV formatted file that contains the database fields you will use when printing.
- Change the "Text Source" to "Variable", then ensure the variable is set to "%EventData%".
- Click the "Database Connection Setup" button and proceed through the wizard steps in order to connect to a CSV formatted file that contains the database fields you will use when printing.
- Click the + button next to Action again.
- Click the Database category then select "For Each Database Record" then click OK.
- Click the Print Document action on the Actions list and drag it underneath the "For Each Database Record" action until it indents. This will make the Print Document action a child of this action.
- In the Document section, select the document you made in the previous section. We'll make it use a variable name later.
- Change the Location to "Computer/Network"
- Type the folder name or use the Browse button to locate it.
- Click the [Import Document Settings...] button
- In the dialog, click OK.
- Click on the Named Data Sources tab and notice the information that has been imported and filled in for you.
The variable names you want to put into the Value field are the field names from your CSV. Variables are marked by surrounding the name with %. One of our field names is Name so the variable equivalent would be %Name%.
- Enter the variables in the matching columns. Using the example database, the values will be as follows:
- If you wish to override the Printer and Label information, you can use variables here too.
- Click on the Print Options tab
- In the Printer box, type %printer%, which matches the printer field in the csv trigger file
- Click on the Document tab.
- In the Document field, remove the name of your btw file while keeping your path in tact. Replace the document name with %btw% which matches the field name in the trigger file. The Document field will have a path and a variable much like this example:
Note that when the path contains a variable, the preview will fail to generate. This is normal.
- Save your integration.
- Click the Test Integration button on the toolbar at the top.
- Click the green Start button in the top right corner.
- In File Explorer, drag the CSV trigger file into the scan folder. The integration will trigger and a label will be printed.
Deploying the integration
After you've tested the integration, you want to deploy it into production.
- Click the Deploy tab then Deploy button on the top toolbar. If there are any changes, you will be prompted to save your integration file before continuing.
- Click the dropdown list and select "This Computer" to deploy locally. Click Next.
- Leave Deploy Now selected and click Finish.
- After a moment, the Administration Console will open and the integration will show as deployed and running.
Applicable to
BarTender 2019 and BarTender 2021
Information
Setting up the label
This type of label does not use a database but instead uses Named Data Sources to handle all its data. This will go over the basics of how to set up this label. For more information, see Named Data Sources in the help file.
- Create a new label.
- Create a text object on the label design area.
- Right click on the label and select properties.
- Select the data source from the list. It'll say "Sample Text."
- Click the box next to the Name field.
- In the dialog, type a unique name and click OK. For this example, use ProductName.
- Ensure the Type is set to Embedded Data.
- When creating more text objects, the Named Data Source dialog will look different. When you click the box next to the Name field, bubble in the first option to create a new name. For example, use ProductType.
- Once you have created as many Named Data Sources as you wish, save the label.
Creating the integration
For your integration, you will need a trigger file. The CSV field names do not need to match your Named Data Source names, as you'll be matching the fields to the Named Data Sources here in the integration. These CSV field names will become a variable in your integration automatically. Make sure that your field names do not use spaces.
This example also includes printer information. Modify the label name and printer name before testing in your own integration. Here is the example:
Name,Food,ID,btw,printer
Seagull Seed Rings,bird food,1236468,Test.btw,Zebra 105
- Open Integration Builder and select "Create New Integration."
- On the new integration dialog, select File Integration and click OK.
- First, set up how the integration will detect files by setting the scan folder. This is where your trigger files will be dropped and the integration will pick them up. For my example, I used a folder on the C drive. Type the folder name or use the Browse button to locate it. Avoid locations such as My Documents or the Desktop as it requires extra permissions to reach those locations.
- Change the File Pattern to match your file. I am using the default of .dat but you can use .txt, .csv, or any type you would like.
- Scroll down to the bottom of this section. If you are using a *.txt file pattern, change the "After Detection" options to a different file extension so the integration will not repeatedly pick up the same file again and again.
- On the lefthand menu, click the + button next to Actions.
- In the dialog, click the Transform category then select "Transform Text to Record Set" then click OK.
- Click the "Database Connection Setup" button and proceed through the wizard steps in order to connect to a CSV formatted file that contains the database fields you will use when printing.
- Change the "Text Source" to "Variable", then ensure the variable is set to "%EventData%".
- Click the "Database Connection Setup" button and proceed through the wizard steps in order to connect to a CSV formatted file that contains the database fields you will use when printing.
- Click the + button next to Action again.
- Click the Database category then select "For Each Database Record" then click OK.
- Click the Print Document action on the Actions list and drag it underneath the "For Each Database Record" action until it indents. This will make the Print Document action a child of this action.
- In the Document section, select the document you made in the previous section. We'll make it use a variable name later.
- Click the [Import Document Settings...] button
- In the dialog, click OK.
- Click on the Named Data Sources tab and notice the information that has been imported and filled in for you.
The variable names you want to put into the Value field are the field names from your CSV. Variables are marked by surrounding the name with %. One of our field names is Name so the variable equivalent would be %Name%.
- Enter the variables in the matching columns. Using the example database, the values will be as follows:
- If you wish to override the Printer and Label information, you can use variables here too.
- Click on the Print Options tab
- In the Printer box, type %printer%, which matches the printer field in the csv trigger file
- Click on the Document tab.
- In the Document field, remove the name of your btw file while keeping your path in tact. Replace the document name with %btw% which matches the field name in the trigger file. The Document field will have a path and a variable much like this example:
Note that when the path contains a variable, the preview will fail to generate. This is normal.
- Save your integration.
- Click the Test Integration button on the toolbar at the top.
- Click the green Start button in the top right corner.
- In File Explorer, drag the CSV trigger file into the scan folder. The integration will trigger and a label will be printed.
Deploying the integration
After you've tested the integration, you want to deploy it into production.
- Click the Deploy tab then Deploy button on the top toolbar. If there are any changes, you will be prompted to save your integration file before continuing.
- Click the dropdown list and select "This Computer" to deploy locally. Click Next.
- Leave Deploy Now selected and click Finish.
- After a moment, the Administration Console will open and the integration will show as deployed and running.
Applicable to
BarTender 2016
Information
Setting up the label
This type of label does not use a database but instead uses Named Data Sources to handle all its data. This will go over the basics of how to set up this label. For more information, see Named Data Sources in the help file.
- Create a new label.
- Create a text object on the label design area.
- Right click on the label and select properties.
- Select the data source from the list. It'll say "Sample Text."
- Click the box next to the Name field.
- In the dialog, type a unique name and click OK. For this example, use ProductName.
- Ensure the Type is set to Embedded Data.
- When creating more text objects, the Named Data Source dialog will look different. When you click the box next to the Name field, bubble in the first option to create a new name. For example, use ProductType.
- Once you have created as many Named Data Sources as you wish, save the label.
Creating the integration
For your integration, you will need a trigger file. The CSV field names do not need to match your Named Data Source names, as you'll be matching the fields to the Named Data Sources here in the integration. These CSV field names will become a variable in your integration automatically. Make sure that your field names do not use spaces.
This example also includes printer information. Modify the label name and printer name before testing in your own integration. Here is the example:
Name,Food,ID,btw,printer
Seagull Seed Rings,bird food,1236468,Test.btw,Zebra 105
- Open Integration Builder and select "Create New Integration."
- On the new integration dialog, select File Integration and click OK.
- First, set up how the integration will detect files by setting the scan folder. This is where your trigger files will be dropped and the integration will pick them up. For my example, I used a folder on the C drive. Type the folder name or use the Browse button to locate it. Avoid locations such as My Documents or the Desktop as it requires extra permissions to reach those locations.
- Change the File Pattern to match your file. I am using the default of .dat but you can use .txt, .csv, or any type you would like.
- Scroll down to the bottom of this section. If you are using a *.txt file pattern, change the "After Detection" options to a different file extension so the integration will not repeatedly pick up the same file again and again.
- On the lefthand menu, click the + button next to Actions.
- In the dialog, click the Transform category then select "Transform Text to Record Set" then click OK.
- Click the "Database Connection Setup" button and proceed through the wizard steps in order to connect to a CSV formatted file that contains the database fields you will use when printing.
- Change the "Text Source" to "Variable", then ensure the variable is set to "%EventData%".
- Click the "Database Connection Setup" button and proceed through the wizard steps in order to connect to a CSV formatted file that contains the database fields you will use when printing.
- Click the + button next to Action again.
- Click the Database category then select "For Each Database Record" then click OK.
- Click the Print Document action on the Actions list and drag it underneath the "For Each Database Record" action until it indents. This will make the Print Document action a child of this action.
- In the Document section, select the document you made in the previous section. We'll make it use a variable name later.
- Click the [Import Document Settings...] button
- In the dialog, click OK.
- Scroll down to the Named Data Sources section and notice the information that has been imported and filled in for you.
The variable names you want to put into the Value field are the field names from your CSV. Variables are marked by surrounding the name with %. One of our field names is Name so the variable equivalent would be %Name%.
- Enter the variables in the matching columns. Using the example database, the values will be as follows:
- If you wish to override the Printer and Label information, you can use variables here too.
- Scroll up to the Print Options Override section
- In the Printer box, type %printer%, which matches the printer field in the csv trigger file
- Scroll up to the Document section.
- In the Document field, remove the name of your btw file while keeping your path in tact. Replace the document name with %btw% which matches the field name in the trigger file. The Document field will have a path and a variable much like this example:
Note that when the path contains a variable, the preview will fail to generate. This is normal.
- Save your integration.
- Click the Test Integration button on the toolbar at the top.
- Click the green Start button in the top right corner.
- In File Explorer, drag the CSV trigger file into the scan folder. The integration will trigger and a label will be printed.
Deploying the integration
After you've tested the integration, you want to deploy it into production.
- Click the Deploy button on the top toolbar. If there are any changes, you will be prompted to save your integration file before continuing.
- Give the integration a name and description if you desire. If none are given, it uses the information from the integration file itself to fill this in.
- Click OK.
- After a moment, the Administration Console will open and the integration will show as deployed and running.