load-data-infile

Load non-uniform data from a txt file into a msql database

I have text files with a lot of uniform rows that I'd like to load into a mysql database, but the files are not completely uniform. There are several rows at the beginning for some miscellaneous information, and there are timestamps about every 6 lines. "LOAD DATA INFILE" doesn't seem like the answer here because of my file format. It d...

MySQL LOAD DATA - Loading a text file with ColumnName=Value format

I've started learning SQL over the past few days, but am stuck while attempting to get my data into the table. The data's stored in a text file with the format: ColumnName1=SomeInteger ColumnName2=SomeInteger ColumnName3=SomeString ... etc So far I've managed to create a table (which has about 150 Columns, that I'm hoping to split up...

MySQL LOAD DATA LOCAL INFILE example in python?

I am looking for a syntax definition, example, sample code, wiki, etc. for executing a LOAD DATA LOCAL INFILE command from python. I believe I can use mysqlimport as well if that is available, so any feedback (and code snippet) on which is the better route, is welcome. A Google search is not turning up much in the way of current info ...

Help with MySQL LOAD DATA INFILE

I want to load a CSV file that looks like this: Acct. No.,1-15 Days,16-30 Days,31-60 Days,61-90 Days,91-120 Days,Beyond 120 Days 2314134101,898.89,8372.16,5584.23,7744.41,9846.54,2896.25 2414134128,5457.61,7488.26,9594.02,6234.78,273.7,2356.13 2513918869,2059.59,7578.59,9395.51,7159.15,5827.48,3041.62 1687950783,4846.85,8364.22,9892.55,...

Importing space-delimited data into MySQL

I have file in the following format: `e00` `e01` `e02` `e03` `e10` `e11` `e12` `e13 Trying to import the data with LOAD DATA INFILE 'file' INTO TABLE 'foo' FIELDS TERMINATED BY ' ' ENCLOSED BY '`' only seems to get the first 3 fields of each line. Is there a way to load the data without altering the file format? ...

MySQL Convert latin1 data to UTF8

I imported some data using LOAD DATA INFILE into a MySQL Database. The table itself and the columns are using the UTF8 character set, but the default character set of the database is latin 1. Because the default character type of the database is latin1, and I used LOAD DATA INFILE without specifying a character set, it interpreted the ...

What is the fastest way to load an XML file into MySQL using C#?

Question What is the fastest way to dump a large (> 1GB) XML file into a MySQL database? Data The data in question is the StackOverflow Creative Commons Data Dump. Purpose This will be used in an offline StackOverflow viewer I am building, since I am looking to do some studying/coding in places where I will not have access to the in...

Whats the best way to INSERT (500-700) words into an MySQL database, for the purpose of a dictionary/histogram

I have to create a histogram/dictionary of all words found in parsing an html file. This includes a dictionary of all words found, and a histogram of their frequency. I cant think of how to do this with PHP/MySQL because there could be potentially 2000 words that would have to be INSERTED at once =/ Any ideas? ...

Moving data from MyISAM to InnoDB - records count error

I've been trying to move some data from a MyISAM database table to a different InnoDB database. The method I used to do that was to Select into outfile from the MyISAM table and then LOAD DATA INTO the InnoDB. The tables don't match perfectly, but the InnoDB table looks like this Field | Type | Null | Key | Defau...

Finding MySQL errors from LOAD DATA INFILE

I have a very large set of files and one of them is showing errors when I import it into mysql from the commandline mysql> prompt. I'm not sure how to check the data so the only thing I have to go by is the fact that the prompt reports 65,535 warnings on import. mysql> use dbname; Database changed mysql> LOAD DATA LOCAL INFILE '/dump.tx...

Using MySQL LOAD DATA INFILE with nonprintable character delimiters

I have some vendor data that has the SOH (ASCII character 1) as the field delimiter and STX (ASCII character 2) as the record delimiter. Is it possible to load this data with LOAD DATA INFILE without pre-processing the file and replacing those characters with something more common? ...

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

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...

Something weird is happening when I try and insert data. Data will not insert.

I have a problem here. I have about 13K rows of data that I want to put into a mysql database. What I notice is that if the row is "short" the insert will happen but if it is long, it fails. I have been trying to figure this out all day and I'm about to give up. Here is the table structure. CREATE TABLE `concordance` ( `term` text NO...

LOAD DATA LOCAL, How do I skip the first line?

I'm trying to Load a CSV file into my MySQL database, But I would like to skip the first line. I fact It contains the name of my columns and no interesting data. Here is the query I'm using: LOAD DATA LOCAL INFILE '/myfile.csv' INTO TABLE tableName FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERM...

MySql bulk load command line tool

Does MySql have a bulk load command line tool like bcp for SQLServer and sqlldr for Oracle? I know there's a SQL command LOAD INFILE or similar but I sometimes need to bulk load a file that is on a different box to the MySQL database. ...

MySQL LOAD DATA INFILE - Loading a file with no primary key

I was trying to load a data file into mysql table using "LOAD DATA LOCAL INFILE 'filename' INTO TABLE 'tablename'". The problem is the source data file contains data of every fields but the primary key is missing ('id' column). I have to add a unique id to each line of source data file otherwise the import will not go through. Is ther...

date conversion in csv to mysql db format

Hi, I am exporting a csv file in to mysql db using load data infile syntax. the date in csv is in 2009/10/31 7:8:57.0 format. Is there any way to convert this while loading to something like 2009-10-31 07:08:57 ? ...

Most efficient way to import data from one MySQL database to another

I'm writing a PHP script which imports data from tables in two different databases into another one. I've got it working ok with sample data, except now I've moved to using data closer resembling its final use: 25+ million records per table, and growing daily. Obviously, efficiency is a bit of a concern. Here's how it current works. I c...

Upload 95Gb csv file into MySQL MyISAM table via Load data infile: CSV engine an alternative?

Hi guys, I'm trying to upload a 95Gb csv file into a MySQL database (MySQL 5.1.36) via the following command: CREATE TABLE MOD13Q1 ( rid INT UNSIGNED NOT NULL AUTO_INCREMENT, gid MEDIUMINT(6) UNSIGNED NOT NULL , yr SMALLINT(4) UNSIGNED NOT NULL , dyyr SMALLINT(4) UNSIGNED NOT NULL , ndvi DECIMAL(7,4) NOT NULL comment 'NA value is 9', r...

Is there a way to insert custom data while loading data from a file in MySQL?

I am using the following statement to load data from a file into a table: LOAD DATA LOCAL INFILE '/home/100000462733296__Stats" INTO TABLE datapoints FIELDS TERMINATED BY '|' LINES TERMINATED BY '\n' (uid1, uid2, status); Now, if I want to enter a custom value into uid1, say 328383 without actually asking it to read it from a file...