---
title: "XML to tab separated for MySQL import"
date: "2013-03-13"
path: "/110-xml-to-tab-separated-for-mysql-import.html"
section: "/ramblings"
aliases:
  - "/110"
  - "/110-xml-to-tab-separated-for-mysql-import"
  - "/110.html"
  - "/ramblings/110-xml-to-tab-separated-for-mysql-import.html"
---

This is a simple perl script used for XML to TSV (tab separated) allowing fast MySQL import through the MySQL `load data infile` [approach](http://dev.mysql.com/doc/refman/5.1/en/load-data.html). For large datasets you can import very quickly using this technique.

<https://gist.github.com/5150902>

Then using a shell script you can import the data in to MySQL by executing the command:

```
mysql -e "LOAD DATA INFILE 'listing.tsv' INTO TABLE table_name" database_name
```

OR possibly depending on the purpose something a little more complicated that dumps the table first using the `mysqlimport</> command:`

```
mysqlimport --lines-terminated-by='\n' --local-infile --delete -h localhost -u user_name -ppassword database_name /home/dev/scripts/listings.tsv
```
