How to insert csv file data into MySQL database

  • Articles written so far : 99

MySQL have this load data function, where we can insert data to a table from external files like csv, txt etc.
The process is quite simple, 1st lets login to mysql via terminal/console.

mysql -u root -p

Enter your MySQL password. Change root to any username(MySQL users) you would wish to login to MySQL.

mysql>

Now lets run the command.

mysql> LOAD DATA LOCAL INFILE ‘/var/www/site/site_users.csv’
INTO TABLE site_users FIELDS
TERMINATED BY ‘;’
ENCLOSED BY ‘”‘
LINES TERMINATED BY ‘\n’
IGNORE 1 LINES;

You will see this if command ran successfully:

Query OK, 370 rows affected (0.00 sec)
Records: 370  Deleted: 0  Skipped: 0  Warnings: 0

In the 1st line, we load a file from local dir and that is the reason we used ‘LOCAL’.
2nd line will insert the data into site_users table.
In the 3rd line we tell the command to break the fields by ; . You can check your csv file in txt format that whether its ; or comma(,).
4th line means that data is enclosed with the double quotes.
And lines are terminated by \n.
Last line will ignore the 1st line, which usually represents the data headers.

One thing i would like to mention here, make sure that the table fields and csv columns sequence matches.
Like name, address, phone are in the table, csv will also be name, address, phone. Which means data will be inserted into the right field.
And yeh column name can be changed, that does not matter like in table first_name and in csv name. What i mean to say here is that the sequence of fields need to match that right data goes to the right field.

That’s it.

Ubuntu 11.04 is released

  • Articles written so far : 99

Ubuntu has announced the latest release of its family OS and this time things are little different than before, we have Ubuntu with new desktop called Unity. I have tested the beta version and it was awesome. I am downloading it ATM and will try it out. So don’t miss it and download it now OR upgrade from your previous version. Upgrade process can be done via update manager(very simple). After upgrading you have the choice to use the new desktop or switch to old(gnome or other) desktop from the login screen. Choice is yours.

Download from Ubuntu Site.

What’s new in it

Features

Good luck and enjoy the fun!


LibreOffice 3.4 Beta 1 Released

  • Articles written so far : 99

Hi folks,

Some interesting news we have here, that Oracle halting commercial interest for OpenOffice. And at the mean time we have beta 1 for LibreOffice, this is now great news. Some of the features are listed below for this release:

  • added navigation buttons to writer
  • Replaced unhide text button by icon buttons
  • Mouse wheel scrolls whole slides
  • Updated slide sorter icons
  • allow ‘select as you type’ aka ‘quick selection’
  • new ‘animated images’ for Throbber controls
  • enable human icon theme
  • treat Excel number format ‘General’ as standard format in Calc
  • change the default sheet print option to “print entire sheet” in Calc
  • don’t toggle the calc formula bar when activating and deactivating a chart in Calc
  • Allow unused master pages to be deleted in master pages control in Impress
  • enable full width by default for ‘Default’ style in Impress

Download it from here.

openSUSE users can follow these instructions, but i would recommend to read in openSUSE forums 1st and install from any beta repos.

More read at linuxjournal.com

openSUSE 11.4 and KDE 4.6.2 Screenshots

  • Articles written so far : 99
2 Talkbacks    

openSUSE 11.4 is released last month, and i have many things to write about it, but at the moment time did not allow me to do so, but i will share things step by step. Today i am going to share some screen shots from my desktop currently running KDE 4.6.2 as my main desktop.

Desktop screen shot with search and launch layout. One can change this from configure desktop while right clicking on the desktop screen. After changing to this layout, there are some settings which one can adjust to his/her taste.

Application utility feature while selecting any application/software on the desktop below the search box.

Search utility on the desktop, very useful one. One can configure what to show in the search in the settings(right click on the desktop screen and choose configure search and launch).

The new and improved KpackageKit in openSUSE 11.4, can show now most of the details for updates, installation. One thing i noticed, it did not show any progress while downloading/installing apps/updates. If one press the detail button, it will show just blank window pane(maybe it’s just me).

Dolphin as usual my preferred file manager. Love the filter and the new search utility w/o nepomuk services to index files.

And Firefox 4 stable from mozilla stable repo. Love the group tabs feature. openSUSE 11.4 by default have Firefox 4 beta 12, if you want to update to the stable release, you need mozilla stable repo. This post might be useful.