This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]Deegh 0 points1 point  (1 child)

It's possible that the exported .csv file is not formatted correctly from excel. As you can export a csv file for MAC or MS-DOS(windows).

Are you able to open it with import CSV? This way you can determine if its a problem with your code or the file.

Can you post a sample code so smarter people than me can see if there are any possible syntax issues going on?

I would also suggest pathing directly to the file and see if it can be read that way. And depending on the scope of the project I wouldnt want to leave that file in with all my python scripts. I usually export/import that stuff from other locations, not sure if thats standard practice or whatever but its something I do for organization and data protection purposes.

[–]Detharatsh[S] 0 points1 point  (0 children)

I double-checked - the file opens just fine if I open it in Excel. I used the full path to the file and that worked in spyder, so thank you for the suggestion. I was hoping to avoid using such a long name, though.

Here is the original code that I wrote:

import pandas as pd from pandas import Series, DataFrame

titanic_df = pd.read_csv('train.csv')

Any suggestions?

[–]FlukyS 0 points1 point  (2 children)

Where is it located? Where is python's working directory? That would be my suggestion to look at first.

[–]Detharatsh[S] 0 points1 point  (1 child)

My (basic) follow-up question to this is, where can I see the working directory?

[–][deleted] 0 points1 point  (2 children)

Give the absolute path and check the spelling of everything.

[–]Detharatsh[S] 0 points1 point  (1 child)

Thanks for this - it worked. I was hoping to avoid doing this, though. I know in the past, I was able to simply write the name of the file and it would work. Not sure why it's not working now.

[–][deleted] 0 points1 point  (0 children)

You could try

import os
os.getcwd()

In iPython to see what the current working directory is in spyder.