I have a csv file where each cell represents an xyz coordinate. How do I get grasshopper to plot the points in a 3 dimensional space?
A point in xyz coordinates is made up of 3 values (x, y and z) and since your csv file doesn’t look like it groups 3 cells in any dimension I’m a bit confused as to which three cells make up a point.
Without some rules of how the cells are to be interpreted into points this would be pretty pointless to plot.
maybe you can give some additional info?
This would be quite easy to accomplish, if your CSV file had a more fitting structure. As mentioned by @lando.schumpich, the point coordinates of a 3d point consist of 3 numbers, one in each direction (i.e. x, y, z).
Your CSV file should consequently have a similar organisation, for instance one point, meaning 3 point coordinates, per row, like this:
“Point1X, Point1Y, Point1Z”
“Point2X, Point2Y, Point2Z”
“Point3X, Point3Y, Point3Z”
Generally speaking, comma-separated values are problematic! You would want to wrap your alpha fields in double-quote characters, like “PointX, PointY, PointZ”, to avoid incorrect processing in the program reading the CSV file.
In your case, you could also insert a carriage return <CR> at the end of each line. This would add a line break to your rows of point coordinates.
Point1X, Point1Y, Point1Z<CR>
Point2X, Point2Y, Point2Z<CR>
Point3X, Point3Y, Point3Z<CR>
That said, if you don’t have control over the creation of the CSV file, you have to figure out a pattern, how the point coordinates are distributed in the file, and reconstruct the point coordinates from there.
By looking at the first item of the list output of your
File component, I can already tell that something is askew.
(1, 2, 3), (4, 5, 6), (7, 8, 9), (10, 11, 12), 13 could be partitioned into 4 3d points (coordinates) and a remainder, the number 13. Weird right?
If you partition like this, you lose one number/coordinate for each row (or line) in the CSV file (since it can’t produce a 3d point on its own).
From here, you should be able to construct your points, however this approach seems off to me.
As mentioned above, a more logically organised CSV file would make much more sense, than constructing 3d points from obviously randomly selected numbers. Why go through the trouble of exporting and importing CSV data, if the data gets scrambled in between and the resulting points are arbitrary?
Furthermore, you should at least provide a file, when asking others to solve your problems! How could anyone find an optimal solution, if all you can look at is a screenshot, showing only fragments of information. Think about it!
Anyway, I hope this clarifies some of your questions.