Jump to content

Null values with decimal/float/double


boniver

Recommended Posts

Hi,  I'm new to phpMyAdmin and relatively new to MySQL.

 

I've got a .csv file which I want to import into a database I've created on MySQL.  My .csv file has a column which has decimal values (for example: 10.1, 40.4, 0.1 etc) as well as some null values (completely empty cells in the excel sheet) which are relevant values in my case.

 

Now my big problem is, whenever I import the .csv file, the null values get automatically converted to 0.0 or 0 even though I've chosen for that attribute to be Null with a default value of Null, and yet it still converts them to 0 which I really don't want as 0 would be considered a value in my data.  This happens with any of the data types (decimal, float and double)

 

I really need help with this, been fiddling around with my database for far too long.  Thanks!

 

 

Link to comment
Share on other sites

I went through the .csv file and deleted/cleared the contents of each empty cell to ensure there wasn't any text or anything in them.

 

How can I import them into the database so that these empty cells are nulls?  I would think many people would run into this problem, especially when importing a large number of rows/columns

Link to comment
Share on other sites

still getting the same thing.  those cells with the text "null" in them get converted to 0.0 for decimal or 0 for float/double

 

i dont get it, this has me really stuck

 

edit: oh i see, empty cells are considered as "".  I dont know how to get around this without manually doing sql update statements which will take forever

 

I don't know how to do scripts.  im just new to this all

Link to comment
Share on other sites

ok, what's driving me even more crazy is i have a similar table that uses decimal (3,3) and the empty cells in that .csv file were successfully turned into NULL on that table.  ive done nothing different with this .csv file

 

i dont know whats going on but something is really screwing with me  :facewall:

Link to comment
Share on other sites

Is it a big deal whether it is an empty string or null?

An empty string would be fine I think, however I've been trying that in the csv file and it still gets converted to 0

 

Here are two lines from my .csv files:

 

10,4,Japan,2007,0.960,0

11,4,Luxembourg,1980,,-3

 

clearly there is a missing value on the second line, but why the hell does it get converted to a 0.0 when I've specified to allow nulls???

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.