My tounge spoke too early, sorry!

Sebastian Haag said:
> Hello,
>
> is it possible to import data into a MySQL-DB from a text-file which does
> not have separating characters (like a comma, semicolon or tab)?
>
> I have a .csv-file in which each column has a different constant lenght
> (so many characters or digits) that I need to import.
>
> For example:
>
> 00721617  20040625      1000  Z
> 00721617  20040626      1000  Z
> 00721617  20040625      1000 OP
> ...............................
>          ^10       ^20        ^30
>
> Now I would like to read this into my database into certain fields. First
> four digits should go to Field1, the next six should go to Field2 and so
> on.
>
> I checked out the LOAD DATA INFILE syntax but couldn't find anything. I
> cannot use the FIELDS TERMINATED BY option.

Not true:

http://dev.mysql.com/doc/mysql/en/LOAD_DATA.html
/*little more than halfway down the page*/

It says:
<quote>
If the FIELDS TERMINATED BY and FIELDS ENCLOSED BY values are both empty
(''), a fixed-row (non-delimited) format is used. [...] For example, if a
column is declared as INT(7), values for the column are written using
seven-character fields. On input, values for the column are obtained by
reading seven characters. LINES TERMINATED BY is still used to separate
lines. [...]
</quote>

>
> Is there a straightforward way to do this or do I have to load it into one
> large field and seperate the fields by using MySQL's string functions?
>
> Thanks in advance for any suggestions!
>
> Sebastian
>
> --
>
> Once a problem is defined - it is half way solved. (Henry Ford)
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]
>
>


-- 

Once a problem is defined - it is half way solved. (Henry Ford)


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to