4

while running the following code I found an error as shown below

data= pd.read_csv("Filtered Data.csv", sep='', encoding='latin-1')

Error shown: ValueError: only single character unicode strings can be converted to Py_UCS4, got length 0

How to get rid of this error?

mechanical_meat
  • 163,903
  • 24
  • 228
  • 223
Ravi
  • 41
  • 1
  • 1
  • 2
  • Obviously that depends on the file you are analising. Provide it as well, or at least the piece of it where the error occurs. –  Jul 07 '16 at 23:17
  • Are you sure you have the encoding right? – miyamoto Jul 07 '16 at 23:19
  • What does this error actually mean ? I never found such type of error while importing csv before! – Ravi Jul 07 '16 at 23:44

1 Answers1

9

The error is thrown because of sep='' It's missing a space. You can use sep=' '. Sep takes a string argument (according to Panda documentation). So it's complaining about an empty string.

You can also use delim_whitespace, see this question.

Community
  • 1
  • 1
marts
  • 658
  • 1
  • 10
  • 15