rbind and cbind join files respectively as if they were stacked on top of each other - bind by row - and as if they were placed side by side - bind by column.
merge allows you to join datasets on shared columns. remember to specify by = list of fields on which to join, and all=TRUE if you want to include rows in which no union took place.
Saturday, 7 May 2011
Friday, 6 May 2011
output CSV from mysql
1. Make sure you've got FILE permission
mysql> grant FILE on *.* to matt;
2. make sure mysql can write to the destination directory - I used /tmp
mysql> select 'hello world' into outfile '/tmp/destination.txt';
3. select your csv output
mysql> grant FILE on *.* to matt;
2. make sure mysql can write to the destination directory - I used /tmp
mysql> select 'hello world' into outfile '/tmp/destination.txt';
3. select your csv output
SELECT order_id,product_name,qty
FROM orders
INTO OUTFILE '/tmp/destination.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';
restoring a mysql db from file
restoring a mysql db from file
mysql> create database charm;
$ mysql -u matt -D charm -p < charm.sql
mysql> grant all on charm.* to matt;
mysql> create database charm;
$ mysql -u matt -D charm -p < charm.sql
mysql> grant all on charm.* to matt;
Subscribe to:
Posts (Atom)