1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| func exportCSV() { let fileName = "SPACE TRACK.csv" let path = NSURL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent(fileName) var csvHead = "number,gravityX,gravityY,gravityZ,userAccelerationX,userAccelerationY,userAccelerationZ,rotationX,rotationY,rotationZ,roll,pitch,yaw,w,wx,wy,wz,time\n"
for dot in dots { csvHead.append("\(dot.number),\(dot.gravityX),\(dot.gravityY),\(dot.gravityZ),\(dot.userAccelerationX),\(dot.userAccelerationY),\(dot.userAccelerationZ),\(dot.rotationX),\(dot.rotationY),\(dot.rotationZ),\(dot.roll),\(dot.pitch),\(dot.yaw),\(dot.w),\(dot.wx),\(dot.wy),\(dot.wz),\(dot.time)\n") }
do { try csvHead.write(to: path!, atomically: true, encoding: .utf8) print("EXPORT") } catch { print("ERROR") }
print(path ?? "not found")
}
|