I'm working on an application that gets a list of x and y coordinates from various data sources. Depending on which data sources I need to go to (which is outside my control), there are multiple ways the data is returned.
- an array of x and y values - [[x1,x2,x3...],[y1, y2, y3...]]
- an array of x,y pairs - [[x1,y1],[x2,y2], ...]
- a dictionary of x:y values - {x1:x2, x2:y2, x3:y3, ...}
- a numpy array of x and y values - array([[x1,x2,x3...],[y1, y2, y3...]])
- a numpy of x,y pairs - array([[x1,y1],[x2,y2], ...])
Using isinstance and len/shape I know I can solve this problem with a switch statement. I was wondering if there was a better way to convert these to a consistent format, or to read these in a consistent way.