Jump to content

load data in file


budimir
Go to solution Solved by budimir,

Recommended Posts

I have a problem with the import of CSV file using code below

	$q_load =   'LOAD DATA LOCAL INFILE "upload/'.$_FILES['filename']['name'].'"
				INTO TABLE kalkulacija_import_cjenik_stavke
				FIELDS TERMINATED BY ";" ENCLOSED BY "\'"
				LINES TERMINATED BY "\r\n"
				IGNORE 1 LINES
				(kataloski_broj, naziv, @cijena_EUR, valuta, @cijena_DD, valuta_DD)
				SET 
				id_cjenika = '.$id_cjenika.' ,
				cijena_EUR = CONVERT(REPLACE(@cijena_EUR, ",", "."), DECIMAL(10,2)) ,
				cijena_DD = CONVERT(REPLACE(@cijena_DD, ",", "."), DECIMAL(10,2)) ,
				godina = '.$godina.'';
				
	mysql_query($q_load) or die (mysql_error());

Problem is that cijena_EUR field is imported but some of the rows have value 0 while in the CSV it has a value. This is happening on just some of the rows but I can't find a reason why. All the rows are formated as number and I don't see a reason why it doesn't import a value from CSV but it imports 0???

 

Any ideas???

Link to comment
Share on other sites

This is CSV data:

 

579 38 10-08 GLOVES TECHNICAL 20 8 CLASS 1 12.33 EUR

579 38 10-09 GLOVES TECHNICAL 20 9 CLASS 1 12.33 EUR

579 38 10-10 GLOVES TECHNICAL 20 10 CLASS 1 12.33 EUR

579 23 80-01 TRIMMER LINE KIT SEMI PRO 679.56 EUR

 

This is what is imported

 

579 38 10-10 GLOVES TECHNICAL 20 10 CLASS 1 0.00

579 38 10-09 GLOVES TECHNICAL 20 9 CLASS 1 0.00

579 38 10-08 GLOVES TECHNICAL 20 8 CLASS 1 0.00

579 23 80-01 TRIMMER LINE KIT SEMI PRO 679.56

Edited by budimir
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.