How to create a CSV integration using Named Data Sources Follow

Avatar

BarTender Content Team


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:

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.

  1. Create a new label.
  2. Create a text object on the label design area.
  3. Right click on the label and select properties.
  4. Select the data source from the list. It'll say "Sample Text."
  5. Click the box next to the Name field.
  6. In the dialog, type a unique name and click OK. For this example, use ProductName.

csv_nds_name.png

  1. 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.

csv_nds_name2.png

  1. 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
  1. Open Integration Builder and select "Create New Integration."
  2. On the new integration dialog, select File Integration and click OK.
  3. 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.
    1. Click the dropdown next to Location and choose "Computer/Network"
    2. Type the folder name or use the Browse button to locate it.
  4. 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.

csv_scan_2022.png

  1. 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.
  2. On the lefthand menu, click the + button next to Actions.
  3. In the dialog, click the Transform category then select "Transform Text to Record Set" then click OK.
  4. Click the + button next to Action again.
  5. Click the Database category then select "For Each Database Record" then click OK.
  6. 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.

csv_nds_child2.png

  1. In the Document section, select the document you made in the previous section. We'll make it use a variable name later.
    1. Change the Location to "Computer/Network"
    2. Type the folder name or use the Browse button to locate it.

csv_document_2022.png

  1. Click the [Import Document Settings...] button
  2. In the dialog, click OK.
  3. Click on the Named Data Sources tab and notice the information that has been imported and filled in for you.

csv_nds_override2.png

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%.

  1. Enter the variables in the matching columns. Using the example database, the values will be as follows:

csv_nds_override3.png

  1. If you wish to override the Printer and Label information, you can use variables here too.
    1. Click on the Print Options tab
    2. In the Printer box, type %printer%, which matches the printer field in the csv trigger file
    3. Click on the Document tab.
    4. 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:

csv_nds_override_name.png

Note that when the path contains a variable, the preview will fail to generate. This is normal.

  1. Save your integration.
  2. Click the Test Integration button on the toolbar at the top.
  3. Click the green Start button in the top right corner.
  4. 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.

  1. 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.
  2. Click the dropdown list and select "This Computer" to deploy locally. Click Next.
  3. Leave Deploy Now selected and click Finish.
  4. After a moment, the Administration Console will open and the integration will show as deployed and running.

csv_integration2.png

 

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.

  1. Create a new label.
  2. Create a text object on the label design area.
  3. Right click on the label and select properties.
  4. Select the data source from the list. It'll say "Sample Text."
  5. Click the box next to the Name field.
  6. In the dialog, type a unique name and click OK. For this example, use ProductName.

csv_nds_name.png

  1. 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.

csv_nds_name2.png

  1. 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
  1. Open Integration Builder and select "Create New Integration."
  2. On the new integration dialog, select File Integration and click OK.
  3. 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.
  4. 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.

csv_scan_2016.png

  1. 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.
  2. On the lefthand menu, click the + button next to Actions.
  3. In the dialog, click the Transform category then select "Transform Text to Record Set" then click OK.
  4. Click the + button next to Action again.
  5. Click the Database category then select "For Each Database Record" then click OK.
  6. 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.

csv_nds_child2.png

  1. In the Document section, select the document you made in the previous section. We'll make it use a variable name later.

csv_document_2016.png

  1. Click the [Import Document Settings...] button
  2. In the dialog, click OK.
  3. Click on the Named Data Sources tab and notice the information that has been imported and filled in for you.

csv_nds_override2.png

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%.

  1. Enter the variables in the matching columns. Using the example database, the values will be as follows:

csv_nds_override3.png

  1. If you wish to override the Printer and Label information, you can use variables here too.
    1. Click on the Print Options tab
    2. In the Printer box, type %printer%, which matches the printer field in the csv trigger file
    3. Click on the Document tab.
    4. 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:

csv_nds_override_name.png

Note that when the path contains a variable, the preview will fail to generate. This is normal.

  1. Save your integration.
  2. Click the Test Integration button on the toolbar at the top.
  3. Click the green Start button in the top right corner.
  4. 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.

  1. 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.
  2. Click the dropdown list and select "This Computer" to deploy locally. Click Next.
  3. Leave Deploy Now selected and click Finish.
  4. After a moment, the Administration Console will open and the integration will show as deployed and running.

csv_integration2.png

 

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.

  1. Create a new label.
  2. Create a text object on the label design area.
  3. Right click on the label and select properties.
  4. Select the data source from the list. It'll say "Sample Text."
  5. Click the box next to the Name field.
  6. In the dialog, type a unique name and click OK. For this example, use ProductName.

csv_nds_name.png

  1. 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.

csv_nds_name2.png

  1. 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
  1. Open Integration Builder and select "Create New Integration."
  2. On the new integration dialog, select File Integration and click OK.
  3. 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.
  4. 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.

csv_scan_2016.png

  1. 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.
  2. On the lefthand menu, click the + button next to Actions.
  3. In the dialog, click the Transform category then select "Transform Text to Record Set" then click OK.
  4. Click the + button next to Action again.
  5. Click the Database category then select "For Each Database Record" then click OK.
  6. 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.

csv_nds_child2.png

  1. In the Document section, select the document you made in the previous section. We'll make it use a variable name later.

csv_document_2016.png

  1. Click the [Import Document Settings...] button
  2. In the dialog, click OK.
  3. Scroll down to the Named Data Sources section and notice the information that has been imported and filled in for you.

csv_nds_override2.png

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%.

  1. Enter the variables in the matching columns. Using the example database, the values will be as follows:

csv_nds_override3.png

  1. If you wish to override the Printer and Label information, you can use variables here too.
    1. Scroll up to the Print Options Override section
    2. In the Printer box, type %printer%, which matches the printer field in the csv trigger file
    3. Scroll up to the Document section.
    4. 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:

csv_nds_override_name.png

Note that when the path contains a variable, the preview will fail to generate. This is normal.

  1. Save your integration.
  2. Click the Test Integration button on the toolbar at the top.
  3. Click the green Start button in the top right corner.
  4. 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.

  1. Click the Deploy button on the top toolbar. If there are any changes, you will be prompted to save your integration file before continuing.
  2. 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.
  3. Click OK.
  4. After a moment, the Administration Console will open and the integration will show as deployed and running.

csv_integration2.png

 

Additional resources

Do you have feedback or questions on this article? We encourage you to post them on our Community Forums