Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. Be respectful, on topic and if you see a problem, Flag it.

If you would like to contact our Community Manager personally, feel free to send a private message or an email.

TableData Reading First Element as String

anthony_pisanoanthony_pisano Member Posts: 1 EDU
edited May 2023 in Community Support
I'm writing a feature to read in a CSV of airfoil data points and plot them on a plane. When reading my CSV the import appears to be formatting the first element of the file as a sting. I have looked at the file, it's not formatted that way in excel or .txt editors. It seems to be local to this. Generically my code is:
annotation { "Name" : "Airfoil points" }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; definition.AFfile is TableData;
debug(context, definition.AFfile, DebugColor.RED);<br>const points = mapArray(definition.AFfile.csvData, function(row) {<br>            // map CSV columns 0, 1 to a vector of X, Y<br>            return vector(row[0], row[1]);<br>        });<br>        debug(context, points, DebugColor.RED);
Both debug points show the element being a string. I cannot figure out why!

I apologize for the formatting of the code snippet. I also can't seem to change that using the formatting choice so here it is again as basic text.
annotation { "Name" : "Airfoil points" }
        definition.AFfile is TableData;
debug(context, definition.AFfile, DebugColor.RED);
const points = mapArray(definition.AFfile.csvData, function(row) {
            // map CSV columns 0, 1 to a vector of X, Y
            return vector(row[0], row[1]);
        });
        debug(context, points, DebugColor.RED);
Sign In or Register to comment.