Get the MovieLens 1M dataset as CSV

How to turn the MovieLens 1M files into clean CSV: what the conversion changes, how to handle commas and encoding, and how to check nothing was lost.

MovieLens 1M is a movie-ratings research dataset published by the GroupLens research group. It is generally described as being distributed as plain-text files that use a double-colon separator rather than as ready-made CSV. Getting a CSV version therefore means running a conversion yourself, and the real question is whether that conversion keeps every value intact. No confirmed evidence was supplied for this review about the dataset's exact row counts, release details, license wording or file encodings, so treat the file details below as things to confirm against the README included in your download.

Is converting to CSV the right move?

For most uses, yes, as long as you use a real CSV writer. The main benefit is compatibility: almost every spreadsheet, database import tool and data library reads comma-separated files with no special settings, while a two-character separator often needs extra configuration. The decisive tradeoff is that movie titles can contain commas. A proper CSV writer wraps those fields in quotes. A simple find-and-replace does not, and it silently produces rows with the wrong number of columns.

Keep the original files when you are loading the data in code that already accepts a custom separator, when you need to compare your work with published results, or when you want an untouched reference copy. Consider tab-separated output instead of CSV if your tools handle tabs well, because titles are unlikely to contain tab characters and TSV usually avoids quoting altogether. Whichever format you choose, keep the originals.

What the download contains

The archive is commonly described as holding three data files plus a README that defines each field. Confirm the file names and column order in your copy before converting.

  • ratings.dat: one rating per line, linking a user, a movie, a rating value and a timestamp
  • movies.dat: a movie identifier, a title with the release year in parentheses, and pipe-separated genres
  • users.dat: a user identifier and demographic fields, including a zip code
  • README: field definitions and the usage license

What the conversion actually changes

Converting delimiters is a change to the stored characters, not a visual effect. The bytes on disk are rewritten in three ways: each separator is replaced, fields containing commas or quotes are wrapped in double quotes, and any quote characters inside a field are doubled. The values themselves should not change. Nothing about display, fonts or reading order is involved; if a value looks different afterward, either the encoding or the parsing went wrong.

The following lines are an invented example built to show the mechanism. They are not taken from the dataset.

Source line:
9999::Example Movie, The (1999)::Comedy|Drama

Correct CSV output (3 fields):
9999,"Example Movie, The (1999)",Comedy|Drama

Naive replace of :: with a comma (parses as 4 fields):
9999,Example Movie, The (1999),Comedy|Drama

The pipe-separated genre list stays inside a single field. Splitting genres into separate columns or rows is a separate restructuring step. Do it on purpose afterward rather than as part of the delimiter swap.

Character encoding

The movies file is widely reported to use Latin-1 (ISO-8859-1) rather than UTF-8, which matters for titles with accented letters. If you read it as UTF-8, you may get a decoding error or garbled characters. The safe approach is to decode with the encoding the file actually uses, split the decoded text, and write the output as UTF-8. Splitting on the separator does not break characters apart once decoding is correct. However, if the wrong encoding is used, the damaged characters are carried into the CSV and can be hard to spot later. Verify the encoding on your copy, for example by checking a few known accented titles after conversion.

Converting with a parser instead of find-and-replace

This script uses only the Python standard library. It adds a header row, quotes fields where needed, and stops if any line has an unexpected number of fields. The column names are descriptive labels; check them against the README.

import csv

files = {
    "ratings.dat": ["user_id", "movie_id", "rating", "timestamp"],
    "movies.dat": ["movie_id", "title", "genres"],
    "users.dat": ["user_id", "gender", "age", "occupation", "zip_code"],
}

for name, columns in files.items():
    out_name = name.replace(".dat", ".csv")
    with open(name, encoding="latin-1", newline="") as src:
        with open(out_name, "w", encoding="utf-8", newline="") as dst:
            writer = csv.writer(dst)
            writer.writerow(columns)
            for line in src:
                fields = line.rstrip("\r\n").split("::")
                if len(fields) != len(columns):
                    raise ValueError(f"{name}: unexpected field count in {line!r}")
                writer.writerow(fields)

If you use pandas, it can read the original files directly. A separator longer than one character is treated as a regular expression and requires the Python parsing engine. Reading every column as text avoids silent type changes, such as zip codes losing leading zeros.

import pandas as pd

movies = pd.read_csv(
    "movies.dat",
    sep="::",
    engine="python",
    header=None,
    names=["movie_id", "title", "genres"],
    encoding="latin-1",
    dtype=str,
)
movies.to_csv("movies.csv", index=False, encoding="utf-8")

Will the CSV stay usable after opening or sharing?

As a file, CSV is plain text. Copying, searching and editing it in a text editor all behave predictably, and correctly quoted fields survive copy and paste between text tools. Most problems happen when a spreadsheet application opens the file and interprets it.

  • Type guessing: spreadsheet apps may treat values that look like numbers or dates as such. Zip codes with leading zeros are the most likely casualty. Import the column as text, or use a guided import instead of opening the file by double-clicking it. Behavior varies by application and settings, so test in your own tool.
  • Encoding detection: some applications guess the encoding of a CSV and may misread UTF-8 accented characters. Whether adding a byte-order mark helps depends on the application, so check a few accented titles after import.
  • Size: the ratings file is large, and the name refers to roughly a million ratings. Check your spreadsheet's row limit before relying on it to open the full file; a database or data library is often the better choice.
  • Timestamps: the README describes the rating timestamps as Unix time in seconds. Keep that column as is and add a converted date column if you need one, so the original value stays available.
  • Accessibility: a header row with clear column names helps anyone navigating the table in a spreadsheet, including people using screen readers. No assistive-technology testing was done for this review, so confirm behavior in the tools your readers actually use.

Before sharing a converted copy, read the usage license in the README; this review does not restate its terms. Sharing your conversion script instead of the converted data lets others reproduce the files from their own download and avoids redistribution questions.

Checking that nothing was lost

  • Line counts: each CSV should have exactly one more line than its source file, the extra line being the header. A CSV reader may count rows differently from a line counter if any field contains a line break, so compare parsed rows as well.
  • Field counts: parse each CSV with a CSV reader and confirm every row has the expected number of columns.
  • Round trip: parse the CSV, join the fields back together with the original separator, and compare the result with the decoded source lines. Any difference points to a quoting or encoding problem.
  • Spot checks: look at titles that contain commas, quotes or accented letters, and at zip codes that start with zero.

Gaps in this review

No confirmed evidence was available on exact row counts, the dataset's release details, the full license wording, or the encoding of each file, and no hands-on tests of specific spreadsheet applications or screen readers were done. The file layout, separator, encoding and timestamp format described here reflect how the dataset is commonly documented. Verify them against the README in your copy before relying on the converted files.