Upload CSV to Moodle

How to prepare and upload CSV files to Moodle: what conversion changes, encoding and delimiter pitfalls, and checks to run before a bulk upload.

Moodle can create or update many records at once from a CSV file: user accounts, courses, enrolments and grades. The hard part is usually not the upload screen. It is the conversion from a spreadsheet or another system into a plain delimited text file that Moodle reads the way you intended. This review covers what that conversion changes, where meaning can be lost, and when a CSV upload is the wrong tool.

Is a CSV upload suitable for your task?

For bulk, repetitive records with a predictable structure, a CSV upload is usually the practical choice. Examples include enrolling a cohort of students, creating a term's worth of course shells, or importing grades from an external tool. The main benefit is consistency. One prepared file applies the same rules to every row, and Moodle shows a preview before committing changes.

The decisive tradeoff is that CSV is plain text with no data types. Anything that depends on spreadsheet behavior is either lost or changed during conversion: formulas, cell formatting, leading zeros, date formats and multiple sheets. If those changes go unnoticed, Moodle accepts the file and stores the altered values.

Direct entry in Moodle's own forms is often the better option for a handful of records, for content that needs rich formatting, or for data with no tested column layout. Quiz questions are a separate case. Moodle's core question import is built around dedicated formats such as Moodle XML and GIFT rather than generic CSV. Check what your installation supports before you build a spreadsheet of questions.

Where Moodle accepts CSV files

Core Moodle includes several CSV-based tools. Their menu locations and exact column names can differ between versions and site configurations, so treat the following as orientation and confirm the details against the documentation for your Moodle version.

  • Upload users (site administration): creates or updates accounts. It typically requires username, firstname, lastname and email columns. Optional columns can enrol users in courses and assign roles, groups or cohorts.
  • Upload courses (site administration): creates or updates courses from columns such as shortname, fullname and a category reference.
  • Grade import (inside a course's gradebook): maps CSV columns to grade items. It matches each row to a user through an identifier such as username, email or ID number.
  • Cohort upload (site administration): creates cohorts in bulk.
  • Plugins and site-specific tools may add further CSV importers. Their formats are defined by the plugin, not by core Moodle.

The user upload screen asks you to choose the delimiter and the file encoding, and it shows a preview of the parsed rows. Use the preview as your first check. If columns appear merged, split or shifted, the delimiter or quoting is wrong. If names show strange symbols, the encoding is wrong.

What the conversion actually changes

Saving a spreadsheet as CSV or TSV rewrites the stored characters. It does not just change how the data looks. Each row becomes a line of text, each cell becomes a field separated by a delimiter character, and any field that contains the delimiter, a quotation mark or a line break must be wrapped in quotation marks. Fonts, colors, column widths and bold text have no place in this format and are discarded. If something in the spreadsheet only looked a certain way because of cell formatting, the CSV keeps the underlying value, not the appearance.

Several common changes can quietly alter meaning:

  • Leading zeros: spreadsheet applications often treat ID numbers such as 00451 as numbers and drop the zeros. The ID then no longer matches the record in Moodle or the source system.
  • Dates: a displayed date may be exported in a different order or format than the one shown on screen. Moodle may then reject it or interpret day and month differently.
  • Long numbers: very long numeric IDs can be converted to scientific notation or rounded.
  • Formulas: only the last calculated result is exported. The calculation itself is gone.
  • Multiple sheets: CSV holds a single table, so only the active sheet is saved.
  • Delimiter by locale: in regions where the comma is the decimal separator, spreadsheet software may export with semicolons instead of commas. Moodle's delimiter setting must match the file.
  • Encoding: some save options produce a legacy regional encoding rather than UTF-8. Accented or non-Latin names are then corrupted if Moodle is told the file is UTF-8.

Unicode can cause a less obvious problem. The same visible name, such as one with an accented letter, can be stored either as a single precomposed character or as a base letter followed by a combining mark. Both render identically, but they are different character sequences. Data copied from different systems can mix the two forms. That can affect exact-match lookups, such as matching a username or ID number against existing records. If a row fails to match an account that appears to exist, check the stored characters, not just the displayed text.

CSV or TSV?

Aspect | CSV (comma or semicolon) | TSV (tab)
Separator | Comma, or semicolon in some locales | Tab character
Fields containing the separator | Must be quoted | Rarely an issue, since tabs seldom appear in names or titles
Risk when edited in a text editor | Quoting mistakes can shift columns | Tabs are invisible and can be replaced by spaces by some editors
Moodle user upload | Supported via the delimiter setting | Tab is offered as a delimiter option in the user upload tool
Other Moodle importers | Generally supported | Check each tool's delimiter options before relying on tabs

Comma-separated files are the most widely expected format. Tab-separated files are worth considering when course names, addresses or other text fields regularly contain commas, because they reduce quoting errors. Whichever you pick, the delimiter you select in Moodle must match the file exactly.

Example of a user upload file

The following illustrates the structure of a user upload file with a header row and course enrolment columns. Email values are shown as placeholders. Column names should be verified against your Moodle version's documentation before use.

username,firstname,lastname,email,course1,role1
jdoe,Jane,Doe,[email address],BIO101,student
asmith,Alex,Smith,[email address],BIO101,student
mlopez,María,López,[email address],BIO101,editingteacher

The third data row contains accented characters. This is the kind of row to inspect in the preview. If it displays correctly there, the file's encoding and Moodle's encoding setting agree. The course1 value refers to the course short name, which must already exist for the enrolment to succeed.

Will the file stay usable after copying or sharing?

A CSV file is plain text, so it can be opened in almost any editor and read by screen readers without special support. That portability has limits.

  • Reopening in a spreadsheet application can repeat the damage. Opening a CSV, making a small edit and saving again may reapply leading-zero removal, date reformatting or an encoding change. Prefer a plain text editor for final corrections, or import the file with columns explicitly set to text.
  • Copying and pasting between applications can change delimiters. Pasting cells from a web page or spreadsheet often produces tab-separated text, not commas.
  • Sharing by email or file storage generally preserves the bytes. However, a recipient whose software assumes a different encoding may see garbled names without the file itself being damaged.
  • Reading order: a CSV is read row by row and field by field. Wide files with many columns are hard to follow with a screen reader in a plain editor. A spreadsheet view with a frozen header row is usually easier for review, as long as it is not used to resave the file.
  • Search and editing inside Moodle depend on the characters actually stored. Names corrupted by an encoding mismatch will appear corrupted in participant lists and searches until they are corrected.

Keep the original spreadsheet as the editable master, and treat the CSV as a generated export. If a human reviewer or an assistive technology user needs to check the data, give them the spreadsheet or a clearly labeled plain-text copy. Do not ask them to work in a file that will be resaved and uploaded.

Checks before you upload

  • Confirm the required columns and exact header names for the specific Moodle tool and version.
  • Export as UTF-8, and select UTF-8 in Moodle unless you have a specific reason to use another encoding.
  • Open the exported file in a plain text editor. Check the delimiter, quoting and leading zeros, and confirm that accented characters look right.
  • Check that referenced courses, categories, roles and cohorts already exist under the identifiers used in the file.
  • Try a small file with a few rows first, ideally on a test site or with test accounts.
  • Read the preview carefully, and choose the upload option that matches your intent, such as adding new records only versus updating existing ones.
  • Keep the results report Moodle shows after the upload, so failed rows can be fixed and resubmitted.

Limits of this review

This overview is based on general, documented behavior of CSV files and Moodle's core upload tools. It does not report test results from any particular Moodle release, hosting provider, plugin or spreadsheet application, and none were supplied as evidence. Menu locations, required fields, accepted delimiters and username rules can vary by version and site settings. How a specific screen reader handles a given file or Moodle page was not tested. Verify version-specific details in your site's documentation, or ask your Moodle administrator, before relying on them for a large upload.