loading very large text file into my sql table - mysql

I have a very large text file of 6.2 GB. I have loaded this to a table in mysql using
load data local infile 'sample.txt'
into table table1 fields terminated by ','
(It took about 20 mins)But the dump was not successful and the data is not readable and not meaningful. I had a similar file but of smaller size in csv format and could successfully load that into sql table. I am unable to open the large text file, How should I convert the text to csv without opening it? or Can anyone share an idea to successfully load the text file to mysql table

Related

How to import data from a .csv file which has 1.88 million rows into MySQL

I am trying to load the data from the below link into MYSQL database scheme
Click here
But it got time out after 30 seconds
I have used the code to set the time to 1000s. but it still does not work
show variables like "net_read_timeout"
set net_read_timeout = 1000;
how should i load 1.88 million row to my schema
LOAD DATA INFILE is your solution. You can read the documentation from the MySQL website and generate the LOAD DATA query for your need. Make sure you put the file in a place where MySQL process can read. It can only load files from certain location. Again it is part of the documentation.
https://dev.mysql.com/doc/refman/8.0/en/load-data.html
LOAD DATA INFILE '/tmp/test.txt' INTO TABLE test FIELDS TERMINATED BY ',' LINES STARTING BY 'xxx';

how to create a mysql table by csv file header?

My goal is to create a MySQL table containing data from my CSV file.
is there any way to do this
i don't know whether it is possible or not thorugh csv. the thing is like i want to generate mysql table using csv headers as filed names i know how to load csv into table which is already created manually but i want to generate table through csv using batch script and below is my batch script to load csv into table through manually
load data local infile "C:\\EQA\\project\\input1.csv"
into table request_table
character set latin1
fields terminated by','
ENCLOSED BY '"'
lines terminated by'\r\n'
IGNORE 1 ROWS
here above code is for to load csv into table in which request_table is existing in db.
but i want to load csv into table dynamically?
is that possible?if so can some one help me out to accomplish this?

How to bulk insert text files into MySQL table?

I just wanted to ask your expertise in bulk insert into mysql table, as of now this script is working fine:
LOAD DATA INFILE 'C:\\test\\cdr_june1.txt' INTO TABLE bod FIELDS TERMINATED BY ',';
But this past few days my text file have different file name, I was thinking to load all the file with .txt extension. How can I do this?

If Query result is big its creating multiple line

I am exporting a oracle table data that has 165 rows into a delimited separated text file.
And then importing into mysql table by Load Data Infile command.
Now the problem is, few row is too long so its created separate line in the text file
while import its creating problem.
my text file data is pipeline(|) separated and enclosed with double quote(").
And its on windows server
Any help will be much appreciated.
its nothing wrong with oracle export,
it is the problem with notepad
i open it in different editor and every row in same line

Replace contents of MySQL table with contents of csv file on a remote server

I'm a newbie here trying to import some data into my wordpress database (MySQL) and I wonder if any of you SQL experts out there can help?
Database type: MySQL
Table name: wp_loans
I would like to completely replace the data in table wp_loans with the contents of file xyz.csv located on a remote server, for example https://www.mystagingserver.com/xyz.csv
All existing data in the table should be replaced with the contents of the CSV file.
The 1st row of the CSV file is the table headings so can be ignored.
I'd also like to automate the script to run daily at say 01:00 in the morning if possible.
UPDATE
Here is the SQL I'm using to try and replace the table contents:
LOAD DATA INFILE 'https://www.mystagingserver.com/xyz.csv'
REPLACE
INTO TABLE wp_loans
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
IGNORE 1 LINES
I would recommend a cron job to automate the process, and probably use BCP (bulk copy) to insert the data into a table... But seeing as you are using MySQL, instead of BCP, try load data in file - https://mariadb.com/kb/en/load-data-infile/