File handling in Python & Grasshopper

Import .csv file

import rhinoscriptsyntax as rs

filter = "CSV file (*.csv)|*.csv|*.txt|All Files (*.*)|*.*||"
file = rs.OpenFileName("Open Point File", filter)

Reload Python Library in Grasshopper

This will allow you to edit your Python library while you work in Grasshopper and Rhino. You do not have to quit and restart Rhino. Example code below for the exturder_turtle library. The same code will work for any external Python file you want to use in your GH code.

# code required so that library reloads appropriately
# must be above other import statements
import sys
to_delete = list()
for module in sys.modules:
    if "extruder_turtle" in module:
      to_delete.append(module)  
        
for module in to_delete: #IMPORTANT, delete old version of library code
    sys.modules.pop(module)
    
from extruder_turtle import * #import the library

reload(extruder_turtle) #IMPORTANT, reload the libary

Create .gcode file

import rhinoscriptsyntax as rs

filter = "GCode (*.gcode)|*.gcode|All Files (*.*)|*.*||"
file = rs.SaveFileName("", filter)

More information

These functions are part of the user interface module in rhinoscript. For more information about them and related functionality see: https://developer.rhino3d.com/api/rhinoscript/user_interface_methods/user_interface_methods.htm