Welcome to RegOnline Help Center: Event Registration Software Sign in | Join | Help
Search for: in Search

tip: loading data from a text file into mysql

Last post 10-10-2009, 3:13 AM by chadnirat. 0 replies.
Sort Posts: Previous Next
  •  10-10-2009, 3:13 AM 4171

    tip: loading data from a text file into mysql

    HI guys

    Here's an example of loading data from a text file into a mysql database.
    This assumes your file is tab delimited, however you can change the SQL command to incorporate different types of delimited text files:

    Code: Select all
    LOAD DATA INFILE '/tmp/add1.txt' IGNORE INTO TABLE accounts FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n' (email, phone, address);


    This add1.txt files is a tab delimited file containing email, phone, and addresses. It is terminated by '\t" (tabs) and is newline terminated "\n". The last part of the sql statement (email, phone, address) maps the tab delimited file columns to columns in the database table. Also, I use IGNORE to ignore duplicate entries on keys. You could alternatively use REPLACE.

    For more info, see the mysql LOAD DATA INFILE documentation!

    thanks
































    ---------------------
    les metiers lies a la protection de l'environnement
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems
Event Registration - Conference Registration - Online Registration - Online Meeting Registration