CSV to Mysql

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • donovan2123
    Top Poster
    • Jan 2010
    • 100

    #1

    CSV to Mysql

    Hi,
    I have been asked to study mysql as the company i currently work for are considering using mysql for there sales dB.

    They are wanting the current csv file the server generates on a daily basis to be converted in to a mysql file prefer automated. Any suggestions?

    Also they want to create a front end or maybe even use a front end already available to access the data ect.

    Much appriecated if anyone can shed some light on mysql as i have never used it.
  • GastonJ
    V.I.P. Member
    • Dec 2009
    • 5505

    #2
    Something along the lines of

    LOAD DATA LOCAL
    INFILE '/tmp/data.txt' INTO TABLE Sales
    COLUMNS TERMINATED BY '\t' ## '\t' is a tab but it could be '\,' if it's a csv
    OPTIONALLY ENCLOSED BY '"'; ##

    Set that up to suit your text file and your table. Then schedule it through cron or whatever to run on a daily basis. Transfer the file to that location before your schedule etc. Depends what O/S you use, but you'd need to delete the text file once imported so you don't import it again, and check it exeist before you import it.
    Last edited by GastonJ; 1 October, 2013, 00:03.
    My master plan is to live forever..... going to plan so far
    Despite the cost of living, it's still very popular.
    No good deed goes unpunished....

    Comment

    Working...