I want to create a CSV with PostgreSQL 9.1 COPY that directly opens correctly with a double-click in crazy German Excel 2010. Using ";"-Delimiter is easy. The encoding is solved, but Excel only recognizes numbers correctly if they use the , as decimal seperator.

Thats what the CSV should look like;

10,7;8,1;90,0;"some, text."

Thats what the CSV looks like now:

10.7;8.1;90.0;"some, text."

Is there a way to do that with COPY?

What I tried:

SHOW lc_numeric;

is set but has no effect.

I found to_char(double precision, text) function. But my table has ~200 columns. Will I have to put to_char( column , 'FM9999999999999999D999999999999999999') for every numeric column? Is there any setting to make COPY change it automagically?

Thanks in advance, Steve

  • 3
    Look at this thread: postgresql.1045698.n5.nabble.com/… I'm afraid that you have to find a solution with to_char. I'd expect performing a conversion with Excel may be easier (no actual idea how to do that, just has some faint memories about doing that years ago). – dezso Mar 6 '13 at 20:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.