• Skip to main content
  • Skip to primary sidebar
  • Skip to footer
Michele Neylon :: Pensieri

Michele Neylon :: Pensieri

Technology, Marketing, Domains, Thoughts

CSV / MySQL Tools?

January 3, 2007 by Michele Neylon 9 Comments

Does anyone know of a tool for working with CSV files and then importing them into MySQL?
I’ve got a flatfile database which has a series of fields that I need to import into MySQL.
Most of the fields in the orginal will map to new ones in the MySQL, while some on both sides will be ignored
There’s about a thousand entries in the database, so I’d rather not do it manually, as it’s not simply a matter of copying and inserting – I will also have to manually change one element associated with each entry….
Any suggestions would be welcome if they run on windows or linux (I don’t have OSX yet)

Related Posts:

  • computer-code-screens
    Dodgy WordPress Developer Tactics
  • privacy-keyboard-keys
    My Privacy Has Been Sold
  • paramount-plus-screenshot
    Paramount+'s UI Makes me Sad
  • Michele-Fest
    If my Music Taste was a Festival ...
  • 283270566_695733724986290_255215121416527661_n
    More Planting and Gardening
  • 287022274_1210906719659909_5337755996671210927_n
    A Glut of Cucumbers

Filed Under: Linux, Open Source, Techie :: Techno ::

Michele is founder and CEO of Irish hosting provider and domain name registrar Blacknight. Read More…

Reader Interactions

Comments

  1. Paul Watson says

    January 3, 2007 at 2:20 pm

    sqlyog has CSV importing as far as I remember (I use the command line now rather than a GUI.)
    A low tech way though is to open the CSV in Excel or some spreadsheet app. You then put your “INSERT INTO abc” command in the first column and then break up the rest of the columns with new columns having “‘,'” in them. Remember to include brackets where necessary. Do it for one line and then use Excel’s repeat-copy feature to copy it all the way down. I then save it as a text file and run it through MySQL. It can be a bit tricky getting the quotes right but it works.

  2. Tom Gleeson says

    January 3, 2007 at 3:36 pm

    Try the LOAD DATA INFILE command http://dev.mysql.com/doc/refman/5.0/en/load-data.html
    Or if you have more time on your hands get to know Pentaho’s Kettle tool http://kettle.pentaho.org/
    It’s a powerful open source GUI fronted ETL tool, will load almost any format into any database.
    Tom

  3. Donncha O Caoimh says

    January 3, 2007 at 3:57 pm

    I generally use a mixture of Openoffice and bash tools when I want to work with csv files. Awk is wonderful for reaaranging columns!

  4. Niall says

    January 3, 2007 at 10:17 pm

    I’ll bring in a copy of Perl For Dummies to you πŸ˜‰

  5. michele says

    January 3, 2007 at 10:21 pm

    Niall
    Does that come in a “retards” edition? πŸ™‚
    Donncha – I’ve been trying something similar but ended up losing an entire field…
    Tom – I couldn’t find any sign of kettle on their site, but thanks anyway
    Paul – Too much like hard work πŸ™‚ It would have been as easy to copy and paste into the new DB

  6. Niall says

    January 3, 2007 at 11:19 pm

    The might have it in a “Cark” edition all right πŸ™‚

  7. Paul Watson says

    January 4, 2007 at 9:15 am

    We managed to get a list of 50,000 feeds into a database using the Excel/OpenOffice method. Took about 10 minutes to setup.
    You could always post it on Mechanical Turk or RentACoder and pay 1c a line πŸ˜‰

  8. James Mernin says

    January 4, 2007 at 10:36 am

    I had to do something similar a few months back and ended up using the LOAD DATA INFILE command as suggested by Tom above. I had a CSV file with around 1000 entries and around 10 fields per entry.
    The first thing I did was to create a new table describing the various fields I planned to import. This was the trickiest part.
    MySQL> create table players (name varchar(20), club varchar(20), value double);
    Them, I imported from the file as follows:
    MySQL> load data local infile “abc.csv” into table players fields terminated by ‘,’;
    The key things here are the use of the “local” keyword before the infile and the “fields terminated by ‘,’
    Best of luck

  9. Michael Brauchl says

    March 25, 2007 at 3:17 pm

    I found myself in the same situation and hacked a small utility to import CSV files to MySQL.
    It recognizes fieldtypes and -lengths automatically on import.
    Drawback, because my English is really bad, i have coded it in German language.
    Youll find the tool here:
    http://mcyra.ath.cx/csvutil/index.html
    And can download it here:
    http://mcyra.ath.cx/dl/download.php?dldfile=3

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

dotblog founder

Mastodon

Archives

  • Bluesky
  • Instagram
  • Threads
  • Twitter

Pages

  • About Me
  • About This Site
  • Archives
  • Comments Policy
  • Contact Me
  • Newsletter
  • Privacy

Blogroll

  • My Mastodon
  • Gordon Hudson
  • Technology.ie Podcast
  • Grandad
  • Paul Savage – BlackDog SEO

Stalking Links

Subscribe to Michele Neylon :: Pensieri

Blogroll

  • Blacknight Blog
  • Damien Mulley
  • Gianni Ponzi
  • Gordon Hudson
  • Grandad
  • My Mastodon
  • Paul Savage – BlackDog SEO
  • Stewart Curry
  • Technology.ie Podcast
  • Tom Doyle

Sites

  • Business Travel Tips
  • Discount Coupon Codes
  • Domain News
  • Fat.ie – my diet blog
  • Film Posters
  • Film Reviews
  • Films
  • Free Desktop Wallpapers
  • Irish Blogger Discussion Forum
  • Irish Stamps
  • Movie Trailers and News
  • Paste.ie

Footer

Site hosted in Ireland by Blacknight - Content copyright Michele Neylon

Copyright © 2025 Β· Magazine Pro on Genesis Framework Β· WordPress Β· Log in