# Format\_float\_out

**URL:** <https://forum.generic-mapping-tools.org/t/format-float-out/4561>\
**Category:** Q&A\
**Created:** [January 3, 2024, 7:59am UTC](https://forum.generic-mapping-tools.org/t/format-float-out/4561 "2024-01-03T07:59:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![esokos](https://avatars.discourse-cdn.com/v4/letter/e/3d9bf3/32.png) [@esokos](https://forum.generic-mapping-tools.org/u/esokos)\
**Post date:** [January 3, 2024, 7:59am UTC](https://forum.generic-mapping-tools.org/t/format-float-out/4561/1 "2024-01-03T07:59:31Z")

</div>

Hello all,

Best wishes for a Happy New Year !!

i think i found a small “bug” in documentation of FORMAT\_FLOAT\_OUT. I was trying to get specific format for a single column in the output (didn’t mind for the rest) but it seems that i must declare the format for **all** output columns, although in the documentation it is written “To give **some** columns a separate format,…” see bellow for GMT6.4.

Best Regards  
Thimios

* * *

**FORMAT\_FLOAT\_OUT** [¶](https://docs.generic-mapping-tools.org/6.4/gmt.conf.html#term-FORMAT_FLOAT_OUT)

Format (C language [printf](https://en.wikipedia.org/wiki/Printf_format_string) syntax) to be used when printing double precision floating point numbers to output files [default is **%.12g**]. For geographic coordinates, see [FORMAT\_GEO\_OUT](https://docs.generic-mapping-tools.org/6.4/gmt.conf.html#term-FORMAT_GEO_OUT). To give some columns a separate format, supply one or more comma-separated _cols_:_format_ specifications, where _cols_ can be specific columns (e.g., 5 for 6th since 0 is the first) or a range of columns (e.g., 3-7). The last specification without column information will override the format for all other columns. Alternatively, you can list N space-separated formats and these apply to the first N columns.

---

<div class="post-metadata">

**Author:** ![Andreas](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@Andreas](https://forum.generic-mapping-tools.org/u/Andreas)\
**Post date:** [January 3, 2024, 9:01am UTC](https://forum.generic-mapping-tools.org/t/format-float-out/4561/2 "2024-01-03T09:01:19Z")

</div>

Please include an example showing the problem, so it can be reproduced.

---

<div class="post-metadata">

**Author:** ![esokos](https://avatars.discourse-cdn.com/v4/letter/e/3d9bf3/32.png) [@esokos](https://forum.generic-mapping-tools.org/u/esokos)\
**Post date:** [January 3, 2024, 11:17am UTC](https://forum.generic-mapping-tools.org/t/format-float-out/4561/3 "2024-01-03T11:17:41Z")

</div>

Hi again,

here it is ..(by the way i am using windows and GMT6.4)

the commands are

rem this is ok  
gmt select test.dat -Ccenter.dat+d4k -R0/20/0/20 --FORMAT\_FLOAT\_OUT=“0-1:%%5.3f,2:%%.0f,3:%%013.2f,4-8:%%2.3f” \> out\_all.dat  
rem this is not ok  
gmt select test.dat -Ccenter.dat+d4k -R0/20/0/20 --FORMAT\_FLOAT\_OUT=“3:%%013.2f” \> out\_one.dat

[center.dat](https://forum.generic-mapping-tools.org/uploads/short-url/yRoq61wXX9Bf8rBygGkLYj4r7vP.dat) (5 Bytes) [test.dat](https://forum.generic-mapping-tools.org/uploads/short-url/iyIKX1kxAfzF5r1dqdRjrquKYGy.dat) (466 Bytes)

---

<div class="post-metadata">

**Author:** ![Andreas](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@Andreas](https://forum.generic-mapping-tools.org/u/Andreas)\
**Post date:** [January 3, 2024, 3:01pm UTC](https://forum.generic-mapping-tools.org/t/format-float-out/4561/4 "2024-01-03T15:01:41Z")

</div>

Condensed script:

```auto
cat<<eof > test.dat
10.00 10.00 1111 010101010.00 1. 5.0 10.00 10.00 10.00
11.00 11.00 1111 010101010.12 1. 5.0 10.00 10.00 10.00
12.00 12.00 1111 010101010.00 2. 5.0 10.00 10.00 10.00
13.00 13.00 1111 010101010.00 3. 5.0 10.00 10.00 10.00
14.00 14.00 1111 010101010.15 5. 5.0 10.00 10.00 10.00
15.00 15.00 1111 010101010.00 6. 5.0 10.00 10.00 10.00
16.00 16.00 1111 010101010.18 7. 5.0 10.00 10.00 10.00
17.00 17.00 1111 010101010.00 8. 5.0 10.00 10.00 10.00
eof

cat<<eof > center.dat
15 15
eof

gmt select test.dat -Ccenter.dat+d4k -R0/20/0/20 --FORMAT_FLOAT_OUT="0-1:%5.3f,2:%.0f,3:%013.2f,4-8:%2.3f"
gmt select test.dat -Ccenter.dat+d4k -R0/20/0/20 --FORMAT_FLOAT_OUT="3:%013.2f"

```

Output:

```auto
13.000	13.000	1111	0010101010.00	3.000	5.000	10.000	10.000	10.000
14.000	14.000	1111	0010101010.15	5.000	5.000	10.000	10.000	10.000
15.000	15.000	1111	0010101010.00	6.000	5.000	10.000	10.000	10.000
16.000	16.000	1111	0010101010.18	7.000	5.000	10.000	10.000	10.000
17.000	17.000	1111	0010101010.00	8.000	5.000	10.000	10.000	10.000
3:0000000013.00	3:0000000013.00	3:0000001111.00	3:0010101010.00	3:0000000003.00	3:0000000005.00	3:0000000010.00	3:0000000010.00	3:0000000010.00
3:0000000014.00	3:0000000014.00	3:0000001111.00	3:0010101010.15	3:0000000005.00	3:0000000005.00	3:0000000010.00	3:0000000010.00	3:0000000010.00
3:0000000015.00	3:0000000015.00	3:0000001111.00	3:0010101010.00	3:0000000006.00	3:0000000005.00	3:0000000010.00	3:0000000010.00	3:0000000010.00
3:0000000016.00	3:0000000016.00	3:0000001111.00	3:0010101010.18	3:0000000007.00	3:0000000005.00	3:0000000010.00	3:0000000010.00	3:0000000010.00
3:0000000017.00	3:0000000017.00	3:0000001111.00	3:0010101010.00	3:0000000008.00	3:0000000005.00	3:0000000010.00	3:0000000010.00	3:0000000010.00

```
