This is a quick way that you can add a right click context to open a csv, xlsx, or json file in an interactive python instance. Note that the name is kind of a misnomer since json files don't actually use pandas. They load as a dictionary as default. I will probably add other files as I go along.
- Python installed and added to PATH
- Pandas library installed (
pip install pandas matplotlib
and others) - Administrative access to modify the Windows Registry
First, download the repo, and then edit the registry:
-
Open the Registry Editor:
- Press
Win + R
, typeregedit
, and press Enter.
- Press
-
Navigate to the following key:
HKEY_CLASSES_ROOT\*\shell
-
Create a new key for the context menu:
- Right-click on
shell
, selectNew
->Key
, and name itOpen in Pandas
. - In the
Open in Pandas
key, set the default value toOpen in Pandas
.
- Set the icon for the context menu entry:
- Right-click on the
Open in Pandas
key, selectNew
->String Value
, and name itIcon
. - Set the value of
Icon
to:C:\path\to\icon\open_in_pandas.ico
- Set the command for the context menu entry:
- Right-click on
Open in Pandas
, selectNew
->Key
, and name itcommand
. - In the
command
key, set the default value to:"C:\path\to\your\bat\file\open_in_pandas.bat" "%1"
Note that you might want to to use a different python interpreter, so you can edit the .bat file to point to a specific interpreter with either directly putting the path to the interpreter. Or you can also just directly add the python interpreter to your registry with something like the string below which bypasses the bat file directly, but I like the flexibility of changing the bat file rather than digging into the registry.
"C:\Path\To\Python\python.exe" -i "C:\path\to\your\script\open_in_pandas.py" "%1"
Since I use this for lightweight and quick analysis of files (sort of in between excel and writing a real script), I have not looked into getting this to work with Anaconda environments. If you need that, then you probably should write a real script.