# Read a CSV path specification and plot the data
import matplotlib.pyplot as plt

# Read and parse the file
filename = input('Enter a file: ')
x = []
y = []
with open(filename, 'r') as file:
    for line in file:
        try:
            pos = [float(l.strip()) for l in line.split(',')]
        except Exception as e:
            continue
        x.append(pos[0])
        y.append(pos[1])

# Set the axis ranges
padding = 0.5
xmin = min(x)
ymin = min(y)
xmax = max(x)
ymax = max(y)
xrange = abs(xmax - xmin)
yrange = abs(ymax - ymin)

if xrange > yrange:
    yoff = (xrange - yrange) / 2
    ymin -= yoff
    ymax += yoff
elif yrange > xrange:
    xoff = (yrange - xrange) / 2
    xmin -= xoff
    xmax += xoff

xmin -= padding
ymin -= padding
xmax += padding
ymax += padding

# Plot the path
plt.plot(x, y)
plt.axis([xmin, xmax, ymin, ymax])
plt.show()
