-1

I am trying to set a folder path as follows:

folderpath = "C:\\Users\NY1\\Dropbox\\Research ideas\\Final Code\\Poject_name"

and I am getting the following error:

SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 9-10: malformed \N character escape

What am I doing wrong?

NNsr
  • 1,023
  • 2
  • 11
  • 25
  • 2
    Is that *really* the string that generates the error? You need to copy/paste or you're unlikely to get any help. – Mark Ransom Jul 23 '15 at 04:16
  • @MarkRansom: Thank you; I updated the question. Thank you for your help – NNsr Jul 23 '15 at 04:18
  • Sorry; it was a dumb question – NNsr Jul 23 '15 at 04:21
  • For paths, you should use or normal slashes (on Windows), or you can use `r"r:\aw\string\prefix"` that suppresses interpretation of characters as escape sequences. – pepr Jul 23 '15 at 06:27

2 Answers2

2

You are not escaping one of the backslashes (before NY1):

folderpath = "C:\\Users\NY1\\Dropbox\\Research ideas\\Final Code\\Poject_name"

...should be:

folderpath = "C:\\Users\\NY1\\Dropbox\\Research ideas\\Final Code\\Poject_name"

Notice that the exception is telling you the location of where this character occurs (position 9-10).

grovesNL
  • 6,016
  • 2
  • 20
  • 32
0

I used ("C:\Users\JOHN-PC\Videos\ml-twitter-sentiment-analysis-develop\data\twittertrain.csv"). to remove this problem. you have \ before users and c.s.v file name .

john2195
  • 1
  • 2