Recently followed a short Python bootcamp and have been trying to work on it myself a bit more, but get stuck at the start. We need to upload the data, but for some reason I can't get it to work. In the example it was done like this:
Correct way apparently
So I figured it was just about the file path, so tried to copy that but don't get it to work
My wrong attempt
Any help would be thoroughly appreciated!
Did you try saving the notebook in the same directory where the CSV file exists and use a relative path to import the CSV?
data/titatic.csv
or
titatic.csv
Related
i am trying to figure out how to read my survey data but i keep getting this error. i feel like i am missing some things when i type out how to specifically find the file i need... and would a dictionary be the best data structure to use for this? the ultimate goal is: by using each voting method to determine a winner from the data that was collected. i plan on using if/else if statements...
Did you check your directory properly? The error says No such file or directory. Provide the full correct dir for your csv file and it should work fine.
In addition to providing a full file path, you can put the csv file with the python script under the same folder and try.
[The current Image of the csv file when I use panda to read it]
I was compelled to delete a few files from the Anaconda folder in my laptop and now when I used anaconda Jupyter notebook to work on a ML problem and used panda to display and read the csv file I see this(as per the image. ::: https://i.stack.imgur.com/XUJxh.png) type of a view, instead of the fine looking tabular format . Can someone please suggest me an idea to fix this.
just write data.head() instead of print data.head()
Check the below code:
This should probably solve the error or doubts.
my program creates a log file on the users desktop using:
file = open(os.path.expanduser("~/Desktop/Log.txt"), 'a')
But later I need to send the log file back to myself using MIME. To send a file it needs the the file directory but I do not know how to find that? I tried doing this:
filename='(os.path.expanduser("~/Desktop/Log.txt"), 'a')'
But this does not work. Is there another way to do this? If there is then please give an example since I am a beginner and don't really know what im doing.
Did you try this one? See if it works.
directory=os.path.dirname(os.path.expanduser("~/Desktop/Log.txt"))
if you want absolute path try
fullpath=os.path.abspath(os.path.expanduser("~/Desktop/Log.txt"))
more convenient functions here:
https://docs.python.org/3/library/os.path.html
First of all, the dbf module is great. I've been using it with great success.
I'm trying to open a dbf file on a network share which is a read-only file system. When I try to open it like this, I get an error which says that the .dbf file is read-only.
thisTable = dbf.Table('/volumes/readOnlyVolume/thisFile.dbf')
thisTable.open()
Looking at the documentation, it looks like there's a way to open a table in read-only mode, but I can't figure it out. If you have a second, would you be able to help me out?
Thanks!
Kyle
Cool, thanks! :)
At this point, you need to specify the open mode when you call thisTable.open(), like this:
thisTable.open(mode='read-only')
or
thisTable.open(mode=dbf.READ_ONLY)
Oh, and here's the PyPI link to the module.
Assuming you're using this module, the magic incantation to open read only is:
dbf1 = Dbf()
dbf1.openFile('county.dbf', readOnly=1)
Hope that helped, if not, do add more detail to your question.
I have an app that calls upon the extension found here. I have the .py file in my /var/www folder so that it can be imported in my python code.
So, I keep getting this error:
File does not exist: /var/www/flask_util.js
in my apache error logs. It looks like, because of the name or something, it wants to find a javascript file. But, it's in python. Here's the line of code in python that import it:
from flask_util_js import FlaskUtilJs
I've tried just changing the name of the file to flask_util.js, but again, nothing. Not entirely sure what is going on here, but I am sure that I have a file in /var/www that it should be reading.
EDIT
I think, actually that the import error is coming from importing it into my HTML when I do this:
{{flask_util_js.js}}
So, what I tried was copy out the JS code from the python and create a new file with it in the correct path. When I did that, I still got the same error on the webpage, however the apache logs don't say anything (which is weird right?). So, it still doesn't work, and I don't know why
So, it's ugly but what I ended up doing was copying over the generated JS file that I could find on my server (didn't actually exist as a document in my repository). Then, apache could find it.
This part is for anyone who is actually using flask_util_js:
However, it wasn't reading in the correct Javascript for the url_mapping so I had to go in a hard-code the correct URLs. Not very scalable, but oh well.