471,073 Members | 1,398 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,073 software developers and data experts.

Import question

Hello,

I am using the LOAD DATA INFILE command to import a text file into
mysql.

However, there is much more text in the file than needed in my tables.
How can I make a selection from the text line. For example position 5 -
10 in field A, position 20-23 in field B, etc

Regards,

Joost.
Jul 23 '05 #1
3 2017
On Tue, 31 May 2005 10:21:47 +0200, in mailing.database.mysql "Joost"
<a@b.c> wrote:
| Hello,
|
| I am using the LOAD DATA INFILE command to import a text file into
| mysql.
|
| However, there is much more text in the file than needed in my tables.
| How can I make a selection from the text line. For example position 5 -
| 10 in field A, position 20-23 in field B, etc


Simple answer: you can't.

What you need to do is import your data into a temporary table.
Massage the data the way you want it within this table.
Update/Replace/Insert you temp data fields into your normal table.
---------------------------------------------------------------
jn******@yourpantsyahoo.com.au : Remove your pants to reply
---------------------------------------------------------------
Jul 23 '05 #2
Jeff North formuleerde de vraag :
On Tue, 31 May 2005 10:21:47 +0200, in mailing.database.mysql "Joost"
<a@b.c> wrote:
Hello,

I am using the LOAD DATA INFILE command to import a text file into
mysql.

However, there is much more text in the file than needed in my tables.
How can I make a selection from the text line. For example position 5 -
10 in field A, position 20-23 in field B, etc


Simple answer: you can't.

What you need to do is import your data into a temporary table.
Massage the data the way you want it within this table.
Update/Replace/Insert you temp data fields into your normal table.
---------------------------------------------------------------
jn******@yourpantsyahoo.com.au : Remove your pants to reply
---------------------------------------------------------------


I was afraid that someone was going to say this...

Anyway, thank you for confirming this.

Joost.

PS: I like the remove your pants part. :D Didn't see that one before...
Jul 23 '05 #3
On Tue, 31 May 2005 19:17:47 +0200, in mailing.database.mysql "Joost"
<a@b.c> wrote:
| Jeff North formuleerde de vraag :
| > On Tue, 31 May 2005 10:21:47 +0200, in mailing.database.mysql "Joost"
| > <a@b.c> wrote:
| >
| >>> Hello,
| >>>
| >>> I am using the LOAD DATA INFILE command to import a text file into
| >>> mysql.
| >>>
| >>> However, there is much more text in the file than needed in my tables.
| >>> How can I make a selection from the text line. For example position 5 -
| >>> 10 in field A, position 20-23 in field B, etc
| >
| > Simple answer: you can't.
| >
| > What you need to do is import your data into a temporary table.
| > Massage the data the way you want it within this table.
| > Update/Replace/Insert you temp data fields into your normal table.
|
| I was afraid that someone was going to say this...
|
| Anyway, thank you for confirming this.


I always use temp tables when importing data. Why?
1. Because you can bet there will be one or two records that are
incorrect and will not import into the main tables correctly.

2. if the data is corrupt then you simply clear out the temp table and
start again. Your main data isn't affected in anyway.

3. is that it is quicker to apply the 'rules' to this small data set
that manipulating the larger set.

4. data can be easily split out to as many tables as required.
---------------------------------------------------------------
jn******@yourpantsyahoo.com.au : Remove your pants to reply
---------------------------------------------------------------
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Kevin MacKenzie | last post: by
reply views Thread by Stian Søiland | last post: by
1 post views Thread by Raaijmakers, Vincent \(GE Infrastructure\) | last post: by
2 posts views Thread by Charles Fineman | last post: by
4 posts views Thread by Bruce W. Roeser | last post: by
3 posts views Thread by SMALLp | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.