尝试使用papaparse读入一行数据 package examples;
import javax.media.j3d.Appearance;
import javax.media.j3d.Group;
import javax.media.j3d.Material;
import javax.media.j3d.Shape3D;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.vecmath.Color3f;
import javax.vecmath.Vector3d;
import com.sun.j3d.utils.geometry.Primitive;
import com.sun.j3d.utils.geometry.Sphere;
public class SphereGroupExperiment extends Group{
Shape3D[] shapes;
int shapesNum=0;
public SphereGroupExperiment( )
{
// radius x,y spacing x,y count appearance
this(0.25f, 0.75f, 0.75f, 5, 5, null, false );
}
public SphereGroupExperiment( Appearance app )
{
// radius x,y spacing x,y count appearance
this( 0.25f, 0.75f, 0.75f, 5, 5, app, false );
}
public SphereGroupExperiment( float radius, float xSpacing, float ySpacing,
int xCount, int yCount, boolean overrideflag )
{
this( radius, xSpacing, ySpacing, xCount, yCount, null, overrideflag );
}
SphereGroupExperiment(float radius, float xSpace, float ySpace, int xCount, int yCount,Appearance app, boolean overrideFlag){
if(app == null){
Material material = new Material();
material.setDiffuseColor(new Color3f(0.0f, 1.0f, 0.0f));
material.setSpecularColor(new Color3f(0.0f, 0.0f, 0.0f));
material.setShininess(0.0f);
app.setMaterial(material);
}
double xStart = -xSpace * (double)(xCount-1)/2.0;
double yStart = -ySpace * (double)(yCount-1)/2.0;
Sphere sphare= null;
TransformGroup trans = null;
Transform3D t = new Transform3D();
Vector3d vec = new Vector3d();
double x, y = yStart, z = 0.0;
shapes = new Shape3D[xCount*yCount];
for (int i = 0 ; i<yCount ; i++){
x = xStart;
for(int j = 0; j<xCount; j++){
vec.set(x,y,z);
t.setTranslation(vec);
trans = new TransformGroup(t);
addChild(trans);
sphare = new Sphere(
radius, // sphere radius
Primitive.GENERATE_NORMALS, // generate normals
25, // 16 divisions radially
app ); // it's appearance
trans.addChild( sphare );
x += xSpace;
shapes[shapesNum] = sphare.getShape();
if (overrideFlag)
shapes[shapesNum].setCapability(Shape3D.ALLOW_APPEARANCE_OVERRIDE_WRITE);
shapesNum++;
}
y += ySpace;
}
}
public Shape3D[] getSphares(){
return shapes;
}
}
,但我只是获取了一个[object Object]数组。我如何console.log()
一行未包装的值?
console.log
答案 0 :(得分:2)
根据Papa Parse结果文档:
data是一个行数组。如果header为false,则行是数组;否则它们是由字段名称键入的数据对象。
此外,您还尝试在每次迭代中记录整个数组。最好不要将for in
用于数组
尝试
file.data.forEach(function(row){
console.log(JSON.stringify(row));
});