0

What am I doing wrong?

Hey all,... currently working with a Python tutorial on YouTube. In the current lesson, it discusses how to transfer/access/append information from a Python file to a text file. In my text file entitled "employees.txt" with random names and assignments, for whatever reason when I input the following: employee_file = open("employees.txt", "r") print (employee_file.read()) employee_file.close() It doesnt return the information in the employees.txt file. Am I supposed to open the text file a certain way? The tutorial doesnt bother to explain how to navigate the Python interface and I dont know if I did it correctly. ,..however when I change the read function to readable,.. I'm returned with a boolean value. ,..what am I doing wrong??🥺🥺

13th Nov 2020, 5:59 PM
M̘aj̼̦. Gͅr̪̗̦e̟̲y͙
M̘aj̼̦. Gͅr̪̗̦e̟̲y͙ - avatar
6 Respostas
+ 8
M̘aj̼̦. Gͅr̪̗̦e̟̲y͙ , if you don't get an error message, and if your file contains some data it should work properly. Try to open the txt fie with your code editor, so you can see if it is correct or not. The file should be found in the same folder as the code you are using.
13th Nov 2020, 6:57 PM
Lothar
Lothar - avatar
+ 2
Lothar same thing I was thinking
13th Nov 2020, 7:03 PM
pNK
pNK - avatar
0
,...code editor?? Lmfaooo
13th Nov 2020, 7:19 PM
M̘aj̼̦. Gͅr̪̗̦e̟̲y͙
M̘aj̼̦. Gͅr̪̗̦e̟̲y͙ - avatar
0
I'll be honest, I kinda freaked out cause I saw that the lesson required the Python script, and then the text file. So I paused and scrambled to figure out how to open one up. I clicked on File > New > and selected a text file. It appeared on the left hand side which shows the pathway underneath the Python file so I assumed everything was Kosher,... apparently it isn't 😔
13th Nov 2020, 7:52 PM
M̘aj̼̦. Gͅr̪̗̦e̟̲y͙
M̘aj̼̦. Gͅr̪̗̦e̟̲y͙ - avatar
0
Also,... the tutorial teaches everything via PyCharm.,.....and the only compatible version for my laptop is 2018.3.7 or whatever. ,...maybe this function is from a newer update?? If so I'm screwed cause that means I could only take my learning so far.
13th Nov 2020, 7:56 PM
M̘aj̼̦. Gͅr̪̗̦e̟̲y͙
M̘aj̼̦. Gͅr̪̗̦e̟̲y͙ - avatar
0
Addendum: I managed to apply the text file to the Python pathway so that it became readable. However, I did so by copying the entire file and pasting it to the Python file itself. There MUST be a simpler way to open a new file within the Oython file directory as opposed to doing it manually as I did. ,..if any1 reads this please save this n00b from his misery
14th Nov 2020, 4:18 AM
M̘aj̼̦. Gͅr̪̗̦e̟̲y͙
M̘aj̼̦. Gͅr̪̗̦e̟̲y͙ - avatar