loading data into pycharm

Hi all 

I can't believe i have not found the answer to this anywhere!! it honestly been so frustrating and i'm surprised its not easier to figure out. 

i cannot load my .dta or .csv files into pycharm and yes i know how to use the import function, that is not the issue. it's the step before that no one seems to explain. 

in Rstudio i have to setup a workspace directory where all my files (documents for example) are stored on my laptop, then i can run code equivalent to import in python and my data appears in the environment. 

i cannot for the life of me figure out how to do this with pycharm, im sure when someone explains this it may be so easy!!

also how do i save packages permanently in pycharm so i dont have to keep adding the packages to each project 

as you can see this has really stressed me  out lol 

so i would be so so appreciative of any help! :) (im new to pycharm if you couldnt tell already lol)

i have to say i think learning the code is the easy part but navigating all the software systems for the first time can take hours if not days to figure out.

thank you in advance :) 

lastly is there a way i can just press enter or something and the code would just run from my editor to the console ?

This is the error i get thrown 

FileNotFoundError: [Errno 2] No such file or directory: 'icu_data_analysis.dta'   <--- how do i help pycharm recognise where this file is stored on my laptop

this is the code i used 

filename = ('icu_data_analysis.dta')
df = pd.read_stata(filename)
0
2 comments

Hello, 

 

I believe the option you are looking for is "Resource roots", please see details here https://www.jetbrains.com/help/pycharm/configuring-project-structure.html

 

 

>lastly is there a way i can just press enter or something and the code would just run from my editor to the console ?

 

There is a shortcut defined for the "Run" action, please see https://www.jetbrains.com/help/pycharm/running-and-debugging-shortcuts.html    

 

Each time you run a program, it creates a Run Configuration (https://www.jetbrains.com/help/pycharm/creating-and-editing-run-debug-configurations.html) that contains the information needed to setup running the program. PyCharm can have multiple run configurations that you choose from the toolbar, just to the left of the green play button.
If you are editing a different file and want to run it, the simplest thing to do is right click in the editor and choose Run `filename'. This will create a run configuration for that file and run it.

It will also remember this as the last-run Run Configuration. To go back to the previous run, either do the right-click thing again, or switch the active run configuration in the toolbar dropdown. (or there is also a shortcut "Quickly select run/debug configuration and debug or edit it.")

 

 

I hope it sheds some light on your questions. 

 

0
Avatar
Permanently deleted user

Thank you i managed to figure it out eventually, your other tips were very helpful- thank you so much :) 

0

Please sign in to leave a comment.