Excel, text files, and other desktop applications









WHO Collaborating Centre for

Surveillance of Antimicrobial Resistance

Boston, Massachusetts

June 2006

BacLink Tutorial:  Excel, text files, and other desktop applications


This tutorial will cover the step-by-step conversion of a Microsoft Excel data file to WHONET using BacLink.  Because the steps are nearly identical, this tutorial will also be relevant if you have: 1. data saved in Microsoft Access, dBASE, EpiInfo, or simple text files; or 2. data exported from a laboratory information system into a text file. 


The tutorial covers the following areas:


     Part 1.     Inspecting your data file

     Part 2.     Preparing your file for BacLink

     Part 3.     Starting BacLink

     Part 4.     Configuring a new file format

     Part 5.     Running the conversion

     Part 6.     Getting started with WHONET


The tutorial assumes that you have already instead WHONET and BacLink on your computer.  If you have not, refer to the WHONET Tutorial: Getting Started.



Part 1.     Inspecting your data file


In this tutorial, you will be working with the file “ExcelDemo.xls” in the folder c:\whonet5\data.  Use “My Computer” or “Excel” to open this file.



When you open this file, you will see the following data.



Before you begin converting your data, you should familiarize yourself with the organization of the information in the file.  The type of data presented here is fairly typical of files created by manual data entry into Excel.


There are a few useful observations from this file that we will come back to later:

1.  Each row of this file corresponds to the results of one isolate.

2.  The file has results from three antibiotics:  ampicillin, ciprofloxacin, and trimethoprim/sulfamethoxazole.  The measurements (6, 8, 12, 24, 30, 32, etc.) suggest that all results were obtained by the disk diffusion test.  If you are uncertain what method was used, ask one of the laboratory staff responsible for doing the tests.

3.  Each column is appropriately labeled with a column “header” indicating the meaning of each field.



Part 2.     Preparing your file for BacLink


Unfortunately, BacLink does not have a direct import option for Excel files, so we need to make some modifications to create a file that can be converted with BacLink.


First of all, you should delete any extraneous information in the Excel file which is not part of the data to be converted – for example graphs or unneeded descriptive information.  The data to be converted should begin in the cell A1, as in the example.  So for the sample file used in this tutorial, no data “cleaning” is needed.


You then need to save the Excel file in a format compatible with BacLink.  The most convenient format is a delimited text file format.  To do this, click on “File”, “Save as”.  Instead of using the default “Excel Workbook” format, click on “Save as type” and select the option “Text (Tab delimited) (*.txt)”. 


Note:  For a step that we will come to later, remember that Excel, by default, is using “Tab” as the field delimiter.



When you select “Text (Tab delimited)” as your file format, Excel will change the name of the file from “ExcelDemo.xls” to “ExcelDemo.txt”.  Now click on “Save”.  When you click on “Save”, you will get two warning messages.



The first message warns you that Excel cannot save all three Excel Sheets as a text file as once.  Since we only want to save the active sheet, click “OK”. 





The second message warns you that you will lose special formatting, such as bold letters, fonts, and lines when you save an Excel file as a text file.  Since we are only interested in the data, and not the Excel formatting of the data, this is not a problem.  So in answer to the question “Do you want to keep the workbook in this format?”, click “Yes”.


We will now leave Excel completely.  Click on “File”, “Exit”. 


Excel will give you one more warning message.




In this warning message, Excel asks if you want to save the changes to the data file.  Since you just saved the file in the previous step, there is no need to save the file again.  So click “No”.


If you look at your c:\whonet5\data folder, you will now see that there is a file called “ExcelDemo.xls” (the original file) and a file called “ExcelDemo.txt” that you just created with Excel.  We will use BacLink to convert the latter file to WHONET format.



Part 3.     Starting BacLink


Start the BacLink program by double-clicking on the BacLink shortcut icon installed on your desktop.  The main BacLink screen should appear.  In the top half of this screen, you will describe the file that you want BacLink to convert, and in the lower part of the screen, you will give a name to the new WHONET file that BacLink will create.



Note:  BacLink is currently available in 17 languages.  To change the language, click on “Select language”, and look for the desired language.

BacLink has two parts:  1. configuring a data conversion and 2. running a data conversion.


In configuration, you describe to BacLink the file structure, codes, and date formats used in your data file.  This only needs to be done once.  Then after configuration is complete, you can run a conversion for any file that has the same structure.  For example, if you configure BacLink for importing your January data, you can then use this same configuration for data from all subsequent months which have the same data file structure.


Part 4 of this tutorial discusses the configuration of a file format.  Part 5 covers the steps in running the conversion.



Part 4.     Configuring a new file format


To convert the sample file, you need to give BacLink enough details for it to perform the conversion.  To do this, click on “New Format”.


Configuration – Laboratory name


Click on the New Format button.  The File Format screen opens. 

From the drop down box, select the Country: World Health Organization.

Enter the Laboratory Name – enter the name of the laboratory.  For this tutorial, enter BacLink Tutorial Hospital.

Enter up to three characters for the Laboratory Code, for example BTH.   The laboratory code that you indicate will be used by BacLink and WHONET as the default file extension for your WHONET data files.



Configuration – File format

     Click on the File Structure button, and the below screen will appear.  Select the options indicated below.


File structure – when you saved the file in Excel, you selected the format “Text (Tab delimited)”.  So in this screen, under the option for “File format”, select “Text, delimited”.

Delimiter – Select the option “Tab”.

File location – For this tutorial, the location of the file is c:\whonet5\data, so no change is required for this question.  In many institutions, data files are placed in a folder on a central server, so you can use this option to indicate the default location for data files.

File name – You can either give the precise name of the data file here at this step or later, just prior to converting the data.  For this tutorial, leave this response unchanged as “*.txt”.

File origin – Since Excel is a Windows program, select “Windows (ANSI)”.  The difference between “DOS (ASCII)” and “Windows (ANSI)” is only important if your data file includes accents (for example é, ñ, ö, ø, etc.) or non-Latin characters (such as in Greek, Russian, Chinese, Thai, etc.).  For English and data files without accents or non-Latin characters, there is no significant difference between the two.





Configution – Antibiotics


You now need to give BacLink information about the antibiotic results in your file.  Click on “Antibiotics”, and give the indicated responses.


1.  Does your file include antibiotic results?  Answer Yes.


2.  Guidelines:  The sample data file in this tutorial represents results tested by the United States CLSI guidelines (Clinical and Laboratory Standards Institute) for performance of antimicrobial susceptibility tests.  So for this question, choose CLSI.  In your institution, if you do not know the answer to this question, ask your laboratory staff.


3.  Data rows.  When someone makes a simple data file with antibiotic test results, there are two common variations in how the results are saved:  one data row = one isolate or one data row = one antibiotic result.  As you observed earlier in this tutorial, all of the results from one isolate are saved in the same data row of the Excel file.  For data entered manually into Excel, this is the most common and logical way of organizing data.


     So in answer to the question:  “The antibiotics of one isolate require how many rows of data?”, give the answer “One row”.


4.  Antibiotic sequence.  For the sample data file in this tutorial, all of the isolates have antibiotic results saved in the sequence: “Ampicillin”, “Ciprofloxacin”, “Trimethoprim/Sulfamethoxazole”.  This is an example of a “Fixed antibiotic sequence”.  For data entered manually into Excel, this is the most common way of organizing data.  So for this answer, select “Fixed antibiotic sequence”. 


     For data exported from relational databases, laboratory information systems or laboratory instruments, a variable sequence is more common.  The first isolate may have results for ampicillin, ciprofloxacin, and trimethoprim/sulfamethoxazole, but the second isolate may have different antibiotics and presented in a different sequence, one antibiotic result in each data row.


5.  Test methods.  The most important routine susceptibility test methods are disk diffusion, MIC, and Etest.  The data presented in this tutorial are disk diffusion results, so click on “Disk diffusion”.


     If your data file includes more than one test method, then BacLink will ask you a few more questions so that it can reliably distinguish results tested by the different methods.


If you have answered all of the questions correctly, your screen should look like the following.  When finished, click “OK”.



Configuration – Data fields


You will now continue with the most important part of configuration – defining the relationship between the data fields in your file and the corresponding data field in WHONET.


You should see the question:  “Does the first row of the data file include the names of the data fields?”  In other words, does the file have a field “header”.  When you inspected the data file earlier in Excel, you saw that indeed each column is labeled appropriately, so the answer to this question is “Yes”. 




Click on “Data fields” to proceed with the configuration of the data fields.  On the left side of this screen, you will see the default list of WHONET fields.  If you want to add additional fields to this list or remove fields from it, click on “Modify the list of data fields”.  For purposes of this tutorial, we will leave the list as it is.




You will now load your data file to the right side of the screen.  Click on “Select a sample data file” and open the file “ExcelDemo.txt”.  If you have followed all steps correctly up to this point, you should see the following.  If you don’t, go back to the previous steps and make sure that you selected “Text, delimited” as the file format and “Tab” as the field delimiter.  You should recognize that BacLink is displaying the first record of the data file on the right side of the screen.  If you click “Next”, you will be able to see additional records.



You will now need to define the relationship between the WHONET fields and your data fields.  To do this, click on a WHONET field on the left, and then click on the corresponding field on the right.  After doing this, click the “=” sign in the middle.  For example, click on “Identification number” on the left, “Medical record number” on the right, and “=”.  Instead of clicking the “=” sign, you could alternatively double-click on “Medical record number” to establish the match.


Continue to do this for the following pairs:

     Identification number = Medical record number

     Date of birth (D/M/Y) = Date of birth

     Location = Location

     Specimen number = Specimen number

     Specimen date = Collection date

     Specimen type = Specimen

     Organism = Organism


After matching the fields, your screen should look like the following.  If you make a mistake, you can use the option “None of the below” to remove an incorrect match.



You will now match up the antibiotic fields.  On the bottom of the left list, you will see an option for “Antibiotic result 1”.  Since the sample data file has three antibiotics, click on “Add” twice.  Then match up these three antibiotics with the three antibiotics on the right. 



There is one final step.  The antibiotics on the left are marked as “Undefined” because BacLink.  To define the antibiotics, click on “Define” or double-click on the antibiotic.  BacLink will show you a screen where you can define the antibiotics.



In the case of ampicillin, BacLink is suggesting a number of possible matches.  Because the laboratory is using CLSI methods, the correct match for ampicillin is the first one given – “Ampicillin (CLSI, BSAC, SFM, DIN, SRGA-10ug)”.  If you are doing disk diffusion testing, it is very important to choose the item with the correct disk potency.  If you are only doing MIC tests and Etests, then it actually does not matter which of the “ampicillins” you choose.


After you select the correct ampicillin, click on “OK”.  Proceed to define the other two antibiotics as well.  When you finish, your screen should look like the below.



You have now completed all of the required configuration steps.  Click on “OK” to return to the file format configuration screen, and “OK” again to return to the main configuration screen.



Configuration – Saving the configuration


You should now save all of the work you have been doing in configuration.  Click on “Save”. 

Give a name to the new BacLink configuration, for example:   bth.cfg

The filename should end in “.cfg”, but if you do not do this, there is no problem.  BacLink will automatically add “.cfg” to the filename that you give.



Then click on “Exit” to leave the configuration area.  The new configuration will appear on your list of BacLink file formats:  “BacLink Tutorial Hospital” with a filename of bth.cfg.




Part 5.     Running the conversion


In Part 4, you configured the import of the sample file.  You will now see how to convert the text file to a WHONET file with this new configuration.  You will also see how to check whether the configuration is working and define any of your local data codes that WHONET doesn’t recognize.


Starting the conversion


Original data file:  Click on the File format for “BacLink Tutorial Hospital” that you configured in the previous step.  In the upper box called “File name” click on “Browse” to select the file “ExcelDemo.txt”.




     New data file

In the lower box, you need to indicate the name of the new WHONET file that you are about to create.  For this tutorial, give the file the name:  “ExcelDemo.bth”.  You can give the new file any name that you like, but it will be convenient for your data file management if all of your data files end with the three-letter code that you gave to your laboratory, in this tutorial “bth”.


If you did these steps properly, your screen should look like the following. 




Inspecting the conversion


Click on “Begin conversion”.  BacLink will display for you results from the conversion of the first three isolates in the original data file.  The purpose is to allow you to visually inspect the accuracy of the conversion.  On the below screen, you see results from the first isolate.  First focus on the middle column to see whether BacLink is reading the data values correctly, and check the final column to see whether BacLink is converting the data values correctly. 



For this first isolate, there seems to be no problem with Identification number, Location, Date of birth, and Specimen number.  There also appears to be no problem with Specimen date – you should always check the reformatting of the date to ensure that you have selected the correct date format (D/M/Y, M/D/Y, MMDDYYYY, Y-M-D, etc.).  You will also notice that BacLink calculates the patient’s age using the date of birth and specimen date fields.


For Organism, you will notice that there are two similar rows:  “Organism” and “Local organism code”.  The first of these if intended for the WHONET organism code, while the second is intended to save the original organism code from you data file without modification.  Since you have not yet defined the correspondence between your local code and the WHONET code, the first of these two rows is blank.  The situation with Specimen type is similar.  In the row “Specimen type”, BacLink leaves the WHONET field blank because it does not know what the corresponding WHONET code is for “Blood”.  In the row “Local specimen code”, the original entry is copied over.  Finally, in the lower box, you will see that BacLink was able to transfer the antibiotic results correctly.


So from this first record, we can conclude that BacLink is reading the data file correctly, and is saving most of the information into the new WHONET file accurately.  However, BacLink has difficulty with the organism and specimen type fields because the codes have not yet been defined.  If you think you may have made a mistake in your configuration, click “Cancel” and return to “Edit format” to make the correction.  Otherwise, click on “Next” to proceed with the second isolate.


In the second isolate, you will notice a small problem that did not appear with the first isolate.  The location code “Medicine 1” has been abridged to “medici”.  This is because the default length of the location field is 6 characters.  This will be easy to fix later by changing the field length to a larger value.



Click on “Next” to see the third isolate, and then “Next” again.  BacLink will now proceed to finish the conversion of the rest of the data file.  BacLink will tell you how many isolates it converted – 10 isolates in this tutorial.  Click on “OK” to continue.




Defining unrecognized codes


When the conversion is finished, BacLink may alert you that it encountered some codes that it did not recognize.  In this tutorial, you should see the below message.  Click “Yes”.




BacLink will show you a summary of all of the different codes that it did not recognize, as in the below screen.



In this tutorial, BacLink indicates that there are unrecognized locations, organisms, and specimen types.  We won’t worry about the locations at this point until the problem with the field lengths is fixed (from six characters to a larger value). 


Click on the row “Organism”.  Now click on “Define codes” to see the following screen with a list of all of the unrecognized organism codes/text.



Click on the first organism “C. albicans” and “Define code”.  BacLink will now suggest a number of possible matches for this organism.  If you see the correct match, click on the organism and click “OK”.



If you do not see the organism listed, then use the search box to look for the correct organism.  For example, instead of “CNS” or “Coagulase-negative staphylococci”, WHONET has an entry “Staphylococcus, coagulase-negative”.  To search for an organism, type one or more letters of the genus name and one or more letters of the species name, for example type “Staph coag” to find possible matches for “CNS”.  For “GC”, you should do a search for something similar to “Neiss gon”.


After you match the first organism, continue to match all of the rest of the organisms.  If you cannot find an appropriate match, you can call the organism “Other” or you can leave it undefined.  Then click, “OK” to return to the list with the other undefined codes.  You will see that the organism row has disappeared because all of the organisms have been defined. 


Note:  If you have a very long list of codes, there is no need to define all of them.  Begin with the most common or important ones.  If you do not define a code, WHONET will leave the corresponding WHONET field blank, but will still save the original organism code in the column “Local organism code”.



Click on the row for “Specimen type” and “Define codes”.




Define the specimen types one at a time, finding the closest match on the WHONET list.  When you finish matching the specimen types, click “OK” to return to the remaining list of unrecognized codes.



Since we will define the locations later, click “Continue”.  BacLink then warns that you have defined some additional codes that were not included during the conversion.  Click “OK” to return to the main BacLink screen.




Running the conversion again...


Now that you have matched some of your codes with the appropriate WHONET codes, run the conversion again.  Click on “Begin conversion”.  BacLink will give you a warning (Warning #1) that the WHONET file that you want to create already exists, and asks whether you want to replace it.  Answer “Yes”, since the first time was just an initial test. 



BacLink will then ask again (Warning #2) just to make sure that you read the question.  Answer “Yes” again.


You will now see the first isolate again, but this time with the appropriate WHONET organism and specimen type codes indicated.  So this conversion is more complete than during your first attempt. 


Click “Next isolate”, and you will see that the problem with the length of the location code field still persists (“medici” instead of “medicine 1”).  Click “Next” and “Next” again to finish the conversion.  BacLink indicates that it converted ten isolates.  Click “OK”, and answer “Yes” to the question about the unrecognized codes.  This time, you will see that the list of unrecognized codes is much shorter than before.  Only the locations remain to be defined.  Click on “Continue” to return to the main BacLink screen.



Editing the configuration


The conversion is working in most respects with the exception of the location codes which are being shortened to six characters.  This is easy to fix.  Click on “Edit format” from the main BacLink screen to return to the configuration part of BacLink.  Click on “File format” and “Data fields”.  This will return you to the screen in which you defined the matches between the fields in the Excel data file and in WHONET. 



Click on “Modify the list of data fields”.  You will see the following screen.  From this screen, you can configure the current fields, add additional ones to the list, and delete fields that you do not need.  Click on the option “Location”.  On the right side of the screen, you will see that this length of this field is set to 6 characters.  Change this to 20.



Then click “OK”, “OK”, “OK”, “Save”, and “Exit.  This should return you to the main BacLink screen.



Running the conversion again...


Click on “Begin conversion”.  Answer “Yes” and “Yes” again to replace the current WHONET file.  BacLink will show you the first isolate, but this is unchanged from before.  Click on “Next’ to see the second isolate.  You will now notice that the location “Medicine 1” is being correctly being saved as “medicine 1”. 



Then continue with the rest of the conversion until you see the list of unrecognized codes.  Click on “Location” and “Define codes”.



For the first item on the list, click on “Define code” to get the following screen.



You will notice that defining location codes is different from defining organism, specimen, and antibiotic codes.  For the latter three, WHONET has a standard list of codes used by all laboratories with WHONET.  For location codes, WHONET simply uses the same code that your laboratory uses.


Defining your location codes serves a different purposes – it allows you to describe the details about the location to BacLink, for example which department/specialty, whether the location is in an inpatient or outpatient area, etc.


For the first location, “5 North”, choose a department of “med=Medicine” and a location type of “inx = Inpatient (non-ICU)”.  Then click “OK”.



  Continue defining the other location codes in the manner using the following suggestions:


          Location                  Institution                Department        Location type

          Diabetes clinic              bth                          med                        out

          ER                               bth                          eme                        eme

          HC5                             oth                          out                          out

          ICU                              bth                          icu                          icu

          Medicine 1                   bth                          med                        inx

          Medicine 2                   bth                          med                        inx

          NICU                            bth                          neo                         icu

          OB-Gyn                       bth                          obg                         inx

          Ortho                           bth                          sur                          in


In this example, HC5 represents a “Health Center #5”, an outpatient clinic outside the hospital.


Defining locations has two important benefits:  1. at the local level, hospital staff will be able to analyze easily data at the level of the ward, department, or inpatient/outpatient status, even if the original data file only had the ward information; and 2. at the national level, defining the location codes permits standardization for purposes of national comparisons and analyses.


After defining all of the location codes, return to the main BacLink screen. 



Running the conversion again... for the last time!


Click on “Begin conversion”, and replace the previous WHONET file.  Look at the conversion for the first isolate.  You will notice that for the location “Ortho”, BacLink is now putting the department equal to “sur=Surgery” because of the location matchings you defined in the previous step.




Then click “Next” and finish the rest of the conversion.  When the conversion is finished, BacLink will return you immediately to the main BacLink screen because all of the undefined codes have now been defined.



Congratulations!  You have successfully finished a BacLink configuration, defined all of the codes needed by WHONET, and converted a sample data file (ExcelDemo.xls) to WHONET format (ExcelDemo.bth).  You can then proceed to WHONET to analyze this file.  Click on “Exit” to leave BacLink.


The configuration that you made will be useful for any file that has this same structure.  For example, if use your January data file to define your BacLink configuration and codes matches, you can use the same configuration to convert your February, March, etc. data.  If BacLink encounters some new codes in the following months, you can define them as they arise over time.



Part 6.     Getting started with WHONET


Now that you have created a valid WHONET file using BacLink, you can proceed to WHONET.  Double-click on your WHONET icon to begin WHONET.




You will notice that the “BacLink Tutorial Hospital” that we are using in this tutorial does not yet appear on the WHONET list of laboratories.  Before you can begin analyzing the sample data file, you will need to create a laboratory configuration



Creating a laboratory configuration


To create a WHONET laboratory configuration, one option would be to use the “New laboratory” option on this screen.  You would need to enter the laboratory name and code, the list of antibiotics, locations, etc.  But fortunately, there is a faster way.


Click on “Cancel” to go to the main WHONET menu.  Click on “File”.  You will notice an option called “Create a laboratory from a data file”.  Click on this option.



Enter the country “World Health Organization”, laboratory = “BacLink Tutorial Hospital”, and laboratory code = “BTH”.  Click “OK”.




On the next screen, WHONET will ask you to select an example of a data file from this laboratory.  Choose the file “ExcelDemo.bth” that you created with this BacLink tutorial, and click “Open”.



WHONET will now examine the file “ExcelDemo.bth” – what antibiotics are present, what data fields, locations, etc.  With this information WHONET can create a matching laboratory configuration.  When WHONET finishes, the program will ask if you want to review the new configuration.  Answer “Yes”.




WHONET will then show you the laboratory configuration that it prepared.



If you click on “Antibiotics”, you will see that WHONET has the three antibiotics present in the original Excel file.  You can also check the antibiotic breakpoints, and configure the panels and profiles if you wish.



If you click on “Locations”, you will see the list of locations from the original file.


If you click on “Data fields”, you will see that the location field has a length of 20 characters, rather than the usual default of 6 characters.



After you explore these screens, click on “Save” to leave the configuration program.


Note:  After creating the configuration utilizing the shortcut described here, you can make any further edits, such as any modifications to the antibiotic breakpoints and profiles, with Modify laboratory in the same way as any WHONET laboratory configuration.



Inspecting the data file


As a final step, click on “Data entry”, “Open data file”, and choose the file “ExcelDemo.bth”.  You will now be in the Data entry program.  Click on “View database” to see the following screen.



WHONET is now showing you the complete contents of the data file created by BacLink.  Inspect this file to see if there are any possible errors – in the dates, codes, antibiotic results, etc.  This will also help to familiarize you with the structure and contents of a WHONET data file.


When you finish, click on “Continue” and “Exit” to return to the main WHONET screen.  Then “File”, “Exit” to leave WHONET completely.


The next time that you enter WHONET, you will see your new laboratory configuration for the “BacLink Tutorial Hospital” on the list.  You can then select this laboratory for laboratory configuration, data entry, or data analysis.



What next?


You have learned how to convert data from common desktop softwares, such as Excel, and text files exported from laboratory information systems.  The steps were:  1. configuration – which only needs to be accomplished once; and 2. running the conversion – which you can repeat as you continue to collect additional data.


You then set up a new WHONET configuration for this laboratory.  With this configuration, you can now analyze your data with WHONET.  If needed, you could also use WHONET for manual data entry of supplemental information that you did not have in your original data file.


For guidance on how to use WHONET for data entry and data analysis, continue with the appropriate tutorials.