If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > CSV import into MySQL rounding up decimal values

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-25-12, 04:43
OscarTT21 OscarTT21 is offline
Registered User
 
Join Date: Jan 2012
Posts: 1
CSV import into MySQL rounding up decimal values

Hi there,

I have searched the forum for this problem and did find a reference to it with an access database which didn't really address my issue but apologies if this has been covered elsewhere on the forum.

I have been trying to import a csv (downloaded from PayPal of my yearly accounts to do my books) into a MySQL db i created. I managed the import fine however the values i.e the transaction amounts which have two decimal places are being rounded up or down when they are imported!

I have set the field types for all the transaction amounts to decimal (19,4) as after research this seemed to be the way to go.

Has anyone had this issue and solved it or knows what im doing wrong?

Much appreciate any help.

Cheers
Reply With Quote
  #2 (permalink)  
Old 01-25-12, 07:33
it-iss.com it-iss.com is offline
Registered User
 
Join Date: Sep 2009
Location: San Sebastian, Spain
Posts: 620
Not sure where your problem is. Can you provide some snippets of file upload (change amounts and names before posting) and also your load data command? I have run a test here and have not found any issue:

Code:
mysql> DROP TABLE IF EXISTS dectest;
Query OK, 0 rows affected (0.00 sec)

mysql> CREATE TABLE dectest(
    -> name VARCHAR(10),
    -> dist DECIMAL(10,2)
    -> );
Query OK, 0 rows affected (0.05 sec)

mysql> 
mysql> LOAD DATA INFILE 'test.txt'
    -> INTO TABLE dectest
    -> FIELDS TERMINATED BY ','
    -> LINES TERMINATED BY '\n'
    -> (name, dist);
Query OK, 4 rows affected (0.01 sec)
Records: 4  Deleted: 0  Skipped: 0  Warnings: 0

mysql> SELECT * FROM dectest;
+------+-------+
| name | dist  |
+------+-------+
| Bob  | 10.23 | 
| Tom  |  9.57 | 
| Eve  | 11.39 | 
| Tim  | 63.21 | 
+------+-------+
4 rows in set (0.00 sec)
__________________
Ronan Cashell
Senior Oracle/MySQL DBA
http://www.it-iss.com
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On