13/4/2019

How to create a .csv file

Why .csv

Comma separated variable or .csv files are simple text files that can be created or read using any spreadsheet, statistical, or text editing software (e.g. even NotePad or TextEdit!!). There's no reason why you need to use Excel to create this file, but that was the request:

  • Universal support
  • Human readable
  • Bullet proof

Open Excel

Open Excel (File… New) and create a new worksheet

Enter variable names

The first row must contain the variable names required for analysis. Order doesn't matter and extra columns will be ignored, but please pay attention to spelling and case

Enter dates of birth and visit

The date format for entering the date of birth (dob) and date of visit (dov) will depend on your version of Excel and how you have configured preferences/ languages:

Calculate the age in months

I will now calculate agemons (age in months) in cell F2. The WHO recommends a conversion factor of 30.4375 days per month. Since my Excel installation returns date differences in days, cell F2 will look like this:

  • = (E2-D2)/30.4375

Calculate the age in months

Alternatively, if you prefer age in calendar months

  • = DATEDIF(D2, E2, "m")

Repeat as needed

You can now enter additional rows. You may want to use the Fill Down function to extend the calculation in cell F2 to the new rows. Check the Help menu if you're unsure where to find it on your version of Excel:

Voilà

Your file should look something like this

Save as .csv

From the File menu, choose Save As. Make sure you choose comma separated variables as your file output format (again, the look will vary depending on which version of Excel and OS you're using)


You can now upload this file to our Shiny apps for plotting growth or calculating anthropometric Z scores (Zapps™ ) using official WHO reference data.

A note for European visitors

If you’re using a European operating system, Excel may use a semi-colon (;) instead of a comma (,) to separate columns when you 'Save As .csv'. Since these files are plain text, it is easy to check by opening your .csv file in any text editor e.g. NotePad on Windows or TextEdit on Mac. If your columns are separated by semi-colons, there are two quick fixes:

  • Open your file in a simple text editor (NotePad, TextEdit) and search-replace all semicolons with commas (so the columns are appropriately separated).

  • Temporarily configure your system as an English keyboard. It takes a second and is reversible. See our FAQ for details.