2

I'm working with OS Highways data, which when loaded into Postgres using ogr2ogr has a few columns that are set as arrays. Geoserver does not like this, so I need to transform the arrays into a simple list of comma separated values.

For example, currently we have:

{Buses,"Goods Vehicles Exceeding 7.5T"}

What I need instead is:

Buses, Goods Vehicles Exceeding 7.5T

And of course the data type needs to be changed to normal 'character varying' instead of the array type 'character varying[]'.

I could probably split the array into separate fields, then recombine, but I was interested to see if anyone had a more elegant/efficient solution. Thanks!

asked Apr 29, 2016 at 15:48

1 Answer 1

1

You could just alter the table and convert the column in one step:

alter table ogrtable
 alter column arrcolumn
 type varchar
 using (array_to_string(arrcolumn, ', '));
answered May 1, 2016 at 23:55
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.