Hello Again. New to Perl.
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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.