A
A
Alexander Lebedev2017-08-11 12:57:47
JavaScript
Alexander Lebedev, 2017-08-11 12:57:47

How to make Python see Russian directories when using Pandas?

Good afternoon. Python 3
Example:

keywords_list_df = pd.read_csv('Папка/MP_test.csv', sep=';', encoding='cp1251')

Conclusion: If you remove the folder in the path (put the file in the script directory) or (!) change the folder name to English - everything reads fine. That is, the problem is obviously with the perception of Russian-language names by the read_csv method. I tried to feed the name of the directory to the variable, via str.encode('utf8') and str.encode('cp1251'), but I get the name of the directory in the error code in the format "\\xd0\\x9c\\xd0\\xb0\\xd0 \\xbd\\xd0\\xb" etc. Actually, I would be grateful for any advice :)
OSError: Initializing from file failed

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
HamSter, 2019-03-30
@simply-web

for(var i = 0; i<20; i++){
  var rand = Math.floor(Math.random() * 10);
  document.write(rand);
}

SO

J
JaxxDexx, 2017-08-11
@sortarage

f = open(u'Папка/MP_test.csv')
keywords_list_df = pd.read_csv(f, sep=';', encoding='cp1251')
f.close()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question