MYSQL Exporting Directly to CSV, Excel Displaying Formated Values as ####### and nulls as \N

StackOverflow https://stackoverflow.com/questions/7780660

  •  10-02-2021
  •  | 
  •  

문제

I'm using a SELECT INTO OUTFILE to extract rows from a database into CSV.

I've got a couple issues I am trying to deal with.

The first is that I am formatting currency values in the format "$135,300.00"

When I open the csv in Excel, it shows all the currency fields as "########" until they are click on.

Also, null values are inserted as "\N", I would like them to simply be empty.

Thanks for any help you can provide.

도움이 되었습니까?

해결책

The #### thing is an Excel feature. It shows any values as such when the cell is too small to show the full number. Just increase the column width until the cells are big enough.

As for the \n thing, the reference says

If the FIELDS ESCAPED BY character is empty, no characters are escaped and NULL is output as NULL, not \N.

So you're probably using a FIELDS ESCAPED BY in the query. It'd help to see the full query you're using.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top