PerceptiveJohn has asked for the wisdom of the Perl Monks concerning the following question:
I have a simple text file that has 2 fields separated by commas and each line ends with a new-line character. I want to aad this text file into a table. Description of table:
Create Table testtable ( field1 int(6) Primry Key, field2 int(4)) engine=myisam;
For the sake of example, my text file has 1 record:
First Field: 055555 Second Field: 1234
Thus the format 055555,1234
Problem: Because both fields in the table are described as INT, if any of the fields coming from the text file have a leading zero, the zero is dropped in the table field. If I change the table field to CHAR instead of INT it works fine.
Here's the Load Data instructions:
LOAD DATA INFILE 'text.txt' Into Table testtable Fields terminated by ',' Lines terminated by '\n';
Any ideas? Thank you.
Edit (davorg): Removed SHOUTING from title
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Load Data in File
by davorg (Chancellor) on Jul 11, 2006 at 14:04 UTC | |
|
Re: LOAD DATA INFILE
by ptum (Priest) on Jul 11, 2006 at 14:26 UTC |