0

I am trying to load a folder (containing about 1000 .txt files) on my Jupyter notebook (Python 3) from the desktop of my WINDOWS computer; so that I can proceed with my analyses relating to NLP. I am using SPaCY instead of NLTK as advised by one of the Udemy course instructors.

I am a novice in the field and had been trying to read textbooks and udemy online courses but those did not help much.

Following one of the NLP courses from Udemy, I tried to load the folder "text folder sample" as follows (it did not work):

gen = os.walk('../text folder sample')

next(gen)

I am seeking your help with lines of codes which will enable my python script to load and proceed with analyzing the files. **Each .txt file is an autobiography, so I am trying to treat each of them as an independent case so that at later stages I can infer which autobiographies are similar (e.g. cluster analyses).

Community
  • 1
  • 1
  • It depends how you started jupyter. Go through answers here - https://stackoverflow.com/questions/35254852/how-to-change-the-jupyter-start-up-folder – Sharun Apr 26 '19 at 17:47

1 Answers1

0

One of the ways to read all the files in a folder is using listdir(path_to_dir) like this example:

files_name = os.listdir(path_to_dir)

it returns list for files in the directory without the full path. So, to read any of that you don this:

file= open(files_name[0],'r')
Zaher88abd
  • 411
  • 7
  • 19