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

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

  •  10-02-2021
  •  | 
  •  

Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top