-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?

4
  • 2
    Is that really the string that generates the error? You need to copy/paste or you're unlikely to get any help. Commented Jul 23, 2015 at 4:16
  • @MarkRansom: Thank you; I updated the question. Thank you for your help Commented Jul 23, 2015 at 4:18
  • Sorry; it was a dumb question Commented Jul 23, 2015 at 4: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. Commented Jul 23, 2015 at 6:27

2 Answers 2

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).

Sign up to request clarification or add additional context in comments.

2 Comments

I need a nap! Thank you. Sorry for dumb question
@NNsr: We all need naps sometimes :-)
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 .

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.