I've a dat file in the following format which I'm trying to load using pandas.

28::Persuasion (1995)::Romance
29::City of Lost Children, The (1995)::Adventure|Sci-Fi
30::Shanghai Triad (Yao a yao yao dao waipo qiao) (1995)::Drama
31::Dangerous Minds (1995)::Drama
32::Twelve Monkeys (1995)::Drama|Sci-Fi
33::Wings of Courage (1995)::Adventure|Romance
34::Babe (1995)::Children's|Comedy|Drama


movies = pd.read_csv('movies.dat')

I'm getting this error

ParserError: Error tokenizing data. C error: Expected 1 fields in line 11, saw 2

Line 11:

11::American President, The (1995)::Comedy|Drama|Romance

I understand that it's because of the comma. One option I found is to skip these lines, which I don't want to. Is it possible to set newline as the delimiter here? Any help will be truly appreciated.

  • $\begingroup$ What is the command you are using? $\endgroup$ Commented May 6, 2018 at 7:46
  • $\begingroup$ Do you want to separate by | or by ::? $\endgroup$ Commented May 6, 2018 at 7:55
  • $\begingroup$ @DavidMasip :: should be fine. later i can sort out the genre which are separated by | $\endgroup$
    – Van Peer
    Commented May 6, 2018 at 7:57

1 Answer 1


You have to tell


the separator that you want to use by doing:

pd.read_csv('movies.dat', sep = '::')

This should work.

  • $\begingroup$ this worked movies = pd.read_csv('movies.dat', sep='::', engine='python'). $\endgroup$
    – Van Peer
    Commented May 6, 2018 at 8:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.