# Remove header from gps object data

**URL:** <https://discourse.nodered.org/t/remove-header-from-gps-object-data/68688>\
**Category:** Developing Nodes\
**Tags:** database, function-node\
**Created:** [7 October 2022 16:19 UTC](https://discourse.nodered.org/t/remove-header-from-gps-object-data/68688 "2022-10-07T16:19:52Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![SplitSecComp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/splitseccomp/32/39802_2.png) [@SplitSecComp](https://discourse.nodered.org/u/SplitSecComp)\
**Post date:** [7 October 2022 16:19 UTC](https://discourse.nodered.org/t/remove-header-from-gps-object-data/68688/1 "2022-10-07T16:19:52Z")

</div>

Hi.

I receive data from a gps and want to write it to a sql database. How do i get rid of the longitude, latitude, altitude, accuracy, provider etc in the object data. I only want to write the actual values to sql.

The following is the data i get from the gps:

object

latitude: -34.1304

longitude: 22.09785

altitude: 110.5

accuracy: 13.399999618530273

vertical\_accuracy: 0

bearing: 0

speed: 0

elapsedMs: 6

provider: "gps"

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [7 October 2022 17:14 UTC](https://discourse.nodered.org/t/remove-header-from-gps-object-data/68688/2 "2022-10-07T17:14:54Z")

</div>

All you need is an INSERT statement which lists the fields you want and the values to put in them.  
But I'm sure from looking at your previous posts that you already know this, so can you explain why this is not applicable?

For example:

 ![Untitled 3](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/d/bd676b964cb6e335230d697909c835a01b2bdcf5.jpeg)

You didn't give enough detail of the input data to do more than guess at where latitude and longitude might be found. An actual example of the data (not a screen capture) would help.

---

<div class="post-metadata">

**Author:** ![SplitSecComp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/splitseccomp/32/39802_2.png) [@SplitSecComp](https://discourse.nodered.org/u/SplitSecComp)\
**Post date:** [8 October 2022 07:48 UTC](https://discourse.nodered.org/t/remove-header-from-gps-object-data/68688/3 "2022-10-08T07:48:38Z")

</div>

:This is how i receive the data from the gps. I want to get rid of the longitude:, latitude: Altitude, etc and only send the actual data to sql.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/7/87a306008f15e73a5b474a7614b56156f74f9e0a.png)

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [8 October 2022 07:55 UTC](https://discourse.nodered.org/t/remove-header-from-gps-object-data/68688/4 "2022-10-08T07:55:23Z")

</div>

In a chnage node  
set `msg.payload`  
to JSONata J: `$$.payload.*`

This will return an array of values  
e.g  
`[-34.130000, 22.09785, -32.4, etc....]`

---

<div class="post-metadata">

**Author:** ![SplitSecComp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/splitseccomp/32/39802_2.png) [@SplitSecComp](https://discourse.nodered.org/u/SplitSecComp)\
**Post date:** [8 October 2022 08:01 UTC](https://discourse.nodered.org/t/remove-header-from-gps-object-data/68688/5 "2022-10-08T08:01:13Z")

</div>

Many thanks that works

---

<div class="post-metadata">

**Author:** ![SplitSecComp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/splitseccomp/32/39802_2.png) [@SplitSecComp](https://discourse.nodered.org/u/SplitSecComp)\
**Post date:** [8 October 2022 08:14 UTC](https://discourse.nodered.org/t/remove-header-from-gps-object-data/68688/6 "2022-10-08T08:14:33Z")

</div>

The following is the data that i receive now. How to i do a insert query into sql?

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/1/119c268adee816362ca62ead7513c06f1b7c7acf.png)

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [8 October 2022 08:17 UTC](https://discourse.nodered.org/t/remove-header-from-gps-object-data/68688/7 "2022-10-08T08:17:30Z")

</div>

The example @jbudd gave explains how to do it (ie: there was no reason to remove the property names as the database has columns where you need to inject the data to - depending on the database setup).

---

<div class="post-metadata">

**Author:** ![SplitSecComp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/splitseccomp/32/39802_2.png) [@SplitSecComp](https://discourse.nodered.org/u/SplitSecComp)\
**Post date:** [8 October 2022 09:20 UTC](https://discourse.nodered.org/t/remove-header-from-gps-object-data/68688/8 "2022-10-08T09:20:59Z")

</div>

Hi @jbud

How should i send you the data?

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [8 October 2022 11:19 UTC](https://discourse.nodered.org/t/remove-header-from-gps-object-data/68688/9 "2022-10-08T11:19:11Z")

</div>

Are you really still having difficulty?

The first example I gave shows how you can construct an SQL INSERT statement.  
So let's break it down:

msg.topic is **INSERT INTO test (latitude, longitude) VALUES (?, ?)**  
The db table is called "test", it has two fields "latitude" and "longitude".  
Two fields to insert, so two qestion mark place holders in the VALUES part.

msg.payload is **[msg.payload.latitude, msg.payload.longitude]**.  
It is an array of values which will be inserted by the mysql node in place of the question marks.  
Two database fields, two question marks, two elements in the array.  
Note that msg.payload.latitude will be the value -34.13034... It will not include the word "latitude"

My example works with the Mariadb node.  
I don't know which SQL database you have, so I have no idea if this is the syntax you need.  
You can probably find out by searching the web or just by trying it.

> [@SplitSecComp](#):
>
> Hi @jbud
> 
> How should i send you the data?

I really think you have enough information to solve this yourself but for future reference:  
If you use a Debug node you can show msg.payload in the right hand column.  
There are two buttons which let you copy the element path eg "msg.payload" or the value. Copy the value.

 ![Untitled 1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/b/eb6b72d92cca70d52a38070c33fedcd9b190fcb2.jpeg)

In the forum editor click on the preformatted text button  
 ![Untitled 3](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/f/bf97c967021e9d67f79e9aea4e7be03fca2f11a2.jpeg)

And paste the copied data over the top of the highlighted text  
 ![Untitled 6](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/3/c3cb6a13395ad0b3007bf8318dd350ff306b5686.jpeg)

---

<div class="post-metadata">

**Author:** ![SplitSecComp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/splitseccomp/32/39802_2.png) [@SplitSecComp](https://discourse.nodered.org/u/SplitSecComp)\
**Post date:** [8 October 2022 12:26 UTC](https://discourse.nodered.org/t/remove-header-from-gps-object-data/68688/10 "2022-10-08T12:26:21Z")

</div>

Many thanks for all the help.

This should get me going 👍

---

<div class="post-metadata">

**Author:** ![SplitSecComp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/splitseccomp/32/39802_2.png) [@SplitSecComp](https://discourse.nodered.org/u/SplitSecComp)\
**Post date:** [8 October 2022 12:58 UTC](https://discourse.nodered.org/t/remove-header-from-gps-object-data/68688/11 "2022-10-08T12:58:10Z")

</div>

Many thanks guys. I managed to get it working.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [7 December 2022 12:59 UTC](https://discourse.nodered.org/t/remove-header-from-gps-object-data/68688/12 "2022-12-07T12:59:00Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
