SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: ASCII -> MySQL

Hybrid View

  1. #1
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Arrow ASCII -> MySQL

    Hey guys,

    I am needing to purchase a database of information for use in MySQL. It comes in "ASCII fixed-length format". Does this mean I can import it into MySQL as a CSV? Should I have any problems doing so?

    Sketch
    Aaron Brazell
    Technosailor



  2. #2
    SitePoint Addict
    Join Date
    Jun 2001
    Location
    Newcastle, England
    Posts
    268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Fixed-length format generally means that it's not comma-seperated, but that the string is well-defined. For example, if each record consisted of a customer id number (up to 6 characters), first name (up to 20 characters), surname (up to 20 characters) and phone number (up to 12 characters), then each record would be a string of 58 characters followed by a line break, and you'd know that the first 6 charcters always constituted the customer number, the next 20 the first name etc.

    Exactly how it's written varies. Elements will sometimes need to be "padded" (e.g. my first name is only 4 characters, so the other 16 must be filled with something - commonly spaces, but they could use something else).

    So examples might be
    Code:
    12    Nick                Wilson              555-5555
    123456SomeonewithaLongNameAndALongSurnameAlso!+44 01234567
    As for importing it to a database, because you know where each element starts and ends it will be very simple to write a script or whatever to insert commas in the appropriate places and create a CSV file. Elements can be trimmed or whatever to remove any padding characters depending on what they use.

    Hmm, not a very coherent reply but I hope you get the gist .
    Nick Wilson [ - email - ]

  3. #3
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good enough. I'll have to wait to actually get my hands on the db to get more specifics. I may have to come ask for help how to turn it into CSV.

    Sketch
    Aaron Brazell
    Technosailor




Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •