load-data-infile

Using LOAD DATA INFILE with arabic data

℡╲_俬逩灬. 提交于 2019-12-24 00:54:28
问题 I am trying to import a .csv file into a table. I have figured out how to get the data inserted by using the following query: LOAD DATA INFILE 'examplesofdata.csv' INTO TABLE coins FIELDS TERMINATED BY ',' ENCLOSED BY '' ESCAPED BY '\\' IGNORE 1 LINES; However for several of my fields I have Arabic content which gets entered as a series of ? I assume this is because I haven't collated the database correctly or I don't fully understand the LOAD DATA INFILE query. Any advice would be greatly

LOAD DATA INFILE only 1 record inserted

﹥>﹥吖頭↗ 提交于 2019-12-23 10:00:56
问题 I have a csv file that I'm trying to import via the command line. But only 1 row is being inserted. They are comma separated values. I'm on a Mac using Excel Mac. I save as a csv file. How can I tell if the lines are terminated by \r or \n or both? Here is the code I used: LOAD DATA LOCAL INFILE '/Users/eric/Documents/contacts_test.csv' INTO TABLE `contacts_tmp` FIELDS TERMINATED BY ',' ESCAPED BY '\\' LINES TERMINATED BY '\n' (clientid,contactid,title,fname,mname,lname,suffixname,salutation

mysqlimport issues “set @@character_set_database=binary” which prevents loading json values

落爺英雄遲暮 提交于 2019-12-23 09:54:45
问题 I have been using mysqlimport without problems for a long time, now as mysql 5.7 added json data type support, I'm trying to use mysqlimport with rows containing json data. Here is an example of a row in csv file that will be imported using mysqlimport: column_A_value,column_B_value,[{"x":20,"y":"some name"}] Notice that the last column type is json. Now when using mysqlimport as the following: mysqlimport -u user -ppass -h localhost --columns='col_A,col_B,col_C' --local --fields-terminated

Importing bulk CSV data in UTF-8 into MySQL

走远了吗. 提交于 2019-12-21 09:27:38
问题 I'm trying to import about 10K rows of UTF-8 encoded data into a new MySQL table. I can do so successfully with LOAD DATA INFILE via MySQL Workbench but it the UTF-8 characters get mangled. I've tested the database otherwise via PHP and it accepts stores UTF-8 charaters fine. The problem seems to be with LOAD DATA INFILE , and I've come across a few threads about this. Does anyone know a workaround, or possibly another similarly easy method to import CSV data? Thank you. RESOLVED: For others

Is it possible to use a LOAD DATA INFILE type command to UPDATE rows in the db?

。_饼干妹妹 提交于 2019-12-20 10:27:19
问题 Pseudo table: | primary_key | first_name | last_name | date_of_birth | | 1 | John Smith | | 07/04/1982 | At the moment first_name contains a users full name for many rows. The desired outcome is to split the data, so first_name contains "John" and last_name contains "Smith". I have a CSV file which contains the desired format of data: | primary_key | first_name | last_name | | 1 | John | Smith | Is there a way of using the LOAD DATA INFILE command to process the CSV file to UPDATE all rows in

Is it possible to use a LOAD DATA INFILE type command to UPDATE rows in the db?

倖福魔咒の 提交于 2019-12-20 10:26:11
问题 Pseudo table: | primary_key | first_name | last_name | date_of_birth | | 1 | John Smith | | 07/04/1982 | At the moment first_name contains a users full name for many rows. The desired outcome is to split the data, so first_name contains "John" and last_name contains "Smith". I have a CSV file which contains the desired format of data: | primary_key | first_name | last_name | | 1 | John | Smith | Is there a way of using the LOAD DATA INFILE command to process the CSV file to UPDATE all rows in

hibernate + mysql + load data in file

ぐ巨炮叔叔 提交于 2019-12-20 06:47:45
问题 Hi I am trying to load data from a file to Mysql DB using hibernate. here is the query, session.createSQLQuery("LOAD DATA INFILE E:/uploaded/NumSerie/NS/NumSerie.txt INTO TABLE prod CHARACTER SET latin1 FIELDS TERMINATED BY ';' LINES TERMINATED BY '\n' IGNORE 1 LINES;").executeUpdate(); But i get the following error, org.hibernate.QueryException: Space is not allowed after parameter prefix ':' [LOAD DATA INFILE E:/uploaded/NumSerie/NS/NumSerie.txt INTO TABLE prod CHARACTER SET latin1 FIELDS

MYSQL LOAD DATA INFILE

纵饮孤独 提交于 2019-12-20 06:39:08
问题 I use LOAD DATA INFILE in mysql. In my input file I have "x" character but I have to save it to database as NULL. How can I do it? 回答1: load data infile... into table ... fields terminated by... lines terminated by ... ( my_field... ) set my_field = if(my_field = 'x', null, my_field); 回答2: load data infile... into table ... fields terminated by... lines terminated by ... ( @var... ) set my_field = if(@var = 'x', null, @var); Thanks to pekka 来源: https://stackoverflow.com/questions/4723522

Problems creating Tables from command line Mysql

偶尔善良 提交于 2019-12-20 05:52:47
问题 When I type in the code into the Terminal it creates the Database but doesn't create the Table. When I type in use "locations" then "Show TABLES" it tells me that no Tables were created. This code should create a Database and the Table then import the the csv file into the database "locations" mysql -u root --password=password -e "CREATE DATABASE locations;" "CREATE TABLE location_T (number1 INT NOT NULL, number2 INT NOT NULL, number3 INT NOT NULL, names VARCHAR(100) NOT NULL,PRIMARY KEY

LOAD DATA from CSV file where doublequote was used as the escape character

蹲街弑〆低调 提交于 2019-12-19 05:34:08
问题 I have a bunch of CSV data that I need to load into a MySQL database. Well, CSV-ish, perhaps. ( edit : actually, it looks like the stuff described in RFC 4180) Each row is a list of comma-separated doublequoted strings. To escape any doublequotes that appear within a column value, double doublequotes are used. Backslashes are allowed to represent themselves. For example, the line: "", "\wave\", ""hello,"" said the vicar", "what are ""scare-quotes"" good for?", "I'm reading ""Bossypants""" if