Importing data from CSV file in mysql

15/02/2009

Use this command to import data from a CSV file into MySQL

LOAD DATA LOCAL INFILE 'data.csv'
INTO TABLE table_name
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
(field1, filed2, field3);

Sample File

"3003","0.039","aster"
"3017","0.03h","affs"
"3018","0.03unit","xfs"

References

http://dev.mysql.com/doc/refman/5.0/en/load-data.html

No Comments

Concatenating multiple rows of a result set

15/02/2009

This is needed when you need to concatenate multiple rows of a result set in MySQL.

[code='sql']
CREATE TABLE services (
id INT UNSIGNED NOT NULL,
client_id INT UNSIGNED NOT NULL,
KEY (id)
);

INSERT INTO services
VALUES (1,1),(1,2),(3,5),(3,6),(3,7);

SELECT id,client_id
FROM services
WHERE id = 3;

+----+-----------+
| id | client_id
+----+-----------+
| 3 | 5
| 3 | 6
| 3 | 7
+----+-----------+

SELECT id,GROUP_CONCAT(client_id)
FROM services
[...] Continue Reading...

No Comments

Adding -pthread to eclipse, for using posix threads

15/02/2009

Problem
Cannot compile c/c++ project with -pthread. Eclipse is complaining about things.
Solution
Eclipse is not configured to put the -pthread argument in the gcc compilation. To solve this, go to the Menu:

Project -> Properties

From the bar on the left:

c/c++ build -> GCC C Compiler -> Miscellaneous

Add the “-pthread” argument into the beginning of the “Other Flags” Also go to:

c/c++ build -> Settings -> GCC C Linker -> Libraries

And include the “pthread”library into the other libraries. Click Apply and rebuild the project. Pthreads must work now.

23 Comments

gEclipse training at University of Cyprus

13/02/2009

There is a gEclipse training on Monday 16th Feb ’09.  We are going to demonstrate the gEclipse platform and its usage. The training will include:

gEclipse installation 
Grid jobs submission
Data management though gEclipse

I am going to present an introduction to Ganga and an example of the “Gridification” of an application.

More information: agenda and registration.

See you there!

No Comments