Solved

Writing to MySql DB from ascii file

Posted on 2007-11-14
2
490 Views
Last Modified: 2008-02-01
I need the sql command for mysql (database info at end of question) for reading the contents of an ascii file and inserting them into a table.  Below is the necessary information to write the query.

File name: c:\test\AD.asc
File contents:

06/29/2007,08:20:00,0.8484
06/29/2007,09:20:00,0.8488
06/29/2007,10:20:00,0.8484
06/29/2007,11:20:00,0.8473
06/29/2007,12:20:00,0.8477
06/29/2007,13:20:00,0.8470
06/29/2007,14:20:00,0.8469

I could delimit the file ascii file to read using spaces or tabs if necessary.

The table to which I would like to add the contents of the file is called:  'datasetsSpecific'.  Below I have outlined the table column names followed by their format and what it should be filled in with.  In advance, thank you very much.

collectedDataID (INT) - FILLED IN WITH A ONE FOR EVERY ENTRY
period (DATETIME) - FILLED IN WITH THE FIRST TWO COLUMNS OF THE FILE CONCATENATED
open (decimal) - FILLED IN WITH COLUMN #3
flatTick (INT) - NOT FILLED IN


Server info:
MySQL 5.0.45-community-nt via TCP/IP
MySQL Client Version 5.1.11
InnoDB tables
0
Comment
Question by:jmokrauer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 17

Accepted Solution

by:
Aleksandar Bradarić earned 500 total points
ID: 20288252
The SQL command you need is `LOAD DATA INFILE`. The syntax is here: http://dev.mysql.com/doc/refman/5.0/en/load-data.html
0
 
LVL 7

Expert Comment

by:Dmitrii
ID: 20288986
It seems to me that this question is already answered here:
http://www.experts-exchange.com/Database/MySQL/Q_22961535.html
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question