Im doing Load Data Infile I've got this code
move_uploaded_file($file_temp,"uploads/master_listing/".$file_name);
$file_path = FCPATH.'/uploads/master_listing/'.$file_name;
$this->db->query("LOAD DATA LOCAL INFILE '".$file_path."'
INTO TABLE fsi_temp_newmasterlist
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\\n'
IGNORE 1 LINES
(SEQUENCENUMBER,NAME,ADDRESS,PICKUPDATE,ENCODERNO,BARCODEVALUE,REMARKS,CLIENT,PROD)
");
I dont know what's wrong in that code I got error Can't find file
Here's my file location myfolder/uploads/master_listing/
My csv file has table head of SEQUENCENUMBER,NAME,ADDRESS,PICKUPDATE,ENCODERNO,BARCODEVALUE,REMARKS,CLIENT,PROD
I really need help.. thanks in advance.
use this
$new_name = str_replace("\\","/",$file_path)
after replace
C:/xampp5.5/htdocs/joel_fsi/fsi2/uploads/master_listing/testfileupload.csv
In your code
C:\xampp5.5\htdocs\joel_fsi\fsi2/uploads/master_listing/testfileupload.csv
They are conflict \ and /
Take look at this Codeigniter path functions definitions
Related
Im trying to import a csv data into my table in mysql by using:
LOAD DATA INFILE "r'/Users/temp/random_file.csv'"
INTO TABLE random_table
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 ROWS;
But I keep getting this error:
LOAD DATA INFILE "/Users/temp/random_file.csv'"
^
SyntaxError: invalid syntax
And I really don't know why. All help is appreciated!
LOAD DATA INFILE "r'/Users/temp/random_file.csv'"
The file name must be given as a literal string. You seem use raw string which is in Python. Change it to
LOAD DATA INFILE '/Users/temp/random_file.csv'
I've looked in previously asked questions and couldn't find the answer.
I created a table and want to load the data from a .CSV file using the following code:
LOAD DATA INFILE 'C:\...\*.csv'
INTO TABLE table_a
FIELDS TERMINATED BY ","
ENCLOSED BY '"'
LINES TERMINATED BY '/n'
IGNORE 1 ROWS;
but keep getting back this:
"Error Code: 1290. The MySQL server is running with the --secure-file-priv option so it cannot execute this statement"
Any suggestions?
PS - once I overcome this, could you please explain how to load .CSV data from an online URL instead of downloading the file first?
I have trying to load the file data into database table. While inserting somewhere it is breaking,please anyone tell me how to find out which line it is breaking?
Here is my function:
LOAD DATA LOCAL INFILE 'filename' INTO TABLE gtac7_rns
FIELDS TERMINATED BY '|'
LINES STARTING BY 'GTAC-LOGS:'
IGNORE 0 LINES (EntryTS,UserName,CmdAuthorized,CmdType,Cmd,DeviceIP,DevicePort,SessionSource,DomainName,DomainId,ServerID,BindIP,ServerPort,Service,CmdArgs,PrivLvl,TaskId) set DeviceIP = INET6_ATON(DeviceIP), SessionSource = INET6_ATON(SessionSource), BindIP = INET6_ATON(BindIP),Cmd = REPLACE(Cmd, '#', '|')
If it's not a big file you can try replace '\n' in notepad++
So the structure of the csv file is like this:
Country,City,AccentCity,Region,Population,Latitude,
ad,aixas,AixĂ s,06,,42.4833333,1.4666667
ad,aixirivali,Aixirivali,06,,42.4666667,1.5
ad,aixirivall,Aixirivall,06,,42.4666667,1.5
ad,aixirvall,Aixirvall,06,,42.4666667,1.5
The problem is that I don't know how to build the Load data query, I mean which separators to use and so on, mabe you guys can help me with an working example.
Does that help you?
load data local infile 'myfile.csv' into table myTable fields terminated by ','
lines terminated by '\n'
(Country,City,AccentCity,Region,Population,Latitude)
I have my csv file in my public folder, and i'm trying to load it from a migration, but I get a file not found error using this script :
ActiveRecord::Base.connection.execute(
"load data local infile '#{RAILS_ROOT}/public/muds_variables.csv' into table muds_variables " +
"fields terminated by ',' " +
"lines terminated by '\n' " +
"(variable_name, definition)")
I've checked and re-checked the file path, and that's definitely where it lives, I've also tried it just using the file name without any of the path, and a few other combos, but I can't make it work :(. can anyone help me out with this?
here's the error :
Mysql::Error: File '/home/chris/rails_projects/muds/public/muds_variables.csv' not found (Errcode: 2): load data local infile '/home/chris/rails_projects/muds/public/muds_variables.csv' into table muds_variables fields terminated by ',' lines terminated by ' ' (variable_name, definition)
-C
the answer, is that this should work if you ACTUALLY have a file named muds_variables.csv my file was named muds variables.csv sorry for the waste :/