Importing .txt files into databases?????

Discussion in 'MySQL' started by purplepixi, Dec 12, 2005.

  1. #1
    Hi,

    I'm kind of new to all this and was hoping someone could help me.
    I've been designing websites for a few years now, they've not been overly complicated and mainly for myself and my friends (I did it as a real job for a bit, but didn't get paid enough)

    Anyway, now my husbands best mate has asked me to help him design a website for business (basically he'll throw the money in and I'll do the hard work), but we will share any profits.

    The website will be selling books. It sounded quite simple, I've used OSCommerce in the past for basic shop needs and I was looking around and have decided to use Zen-Cart for this one. Anyway I can do all the bits and bobs to get that working, thats not a problem.

    My husbands mate wanted me to look into getting a book dropshipper, which we did, and its taken nearly 2 months but we now have an account - they are basically a wholesaler that will dropship the books for us.

    The problem is we've been asking since we contacted them, what format their data came in. I was hoping it was going to be access or excel, or something like that.

    No, its .txt.

    My HUGE problem, is what do I do with the data. I need to get it into some format so I can upload it into MySQL on the server. However I'm stumped, I can't seem to do anything with it. They have 470,000 books available in stock and over 2,000,000 on special delivery, I think I may be here for the rest of my life should I have to input them individually.

    I have tried to inport into Access, but it doesn't do what I want.

    Below is some example data:

    **
    IB 1859060196
    BI PAPERBACK
    AU SHINE, NORMAN
    BC VXFN
    CO UK
    PD 19990923
    NP 128
    RP 9.99
    RI 9.99
    RE 9.99
    PU CONNECTIONS BOOK PUBLISHING
    YP 1999
    TI NUMEROLOGY
    TI YOUR CHARACTER AND FUTURE REVEALED IN NUMBERS
    EA 9781859060193
    RF R
    SG 2
    GC M01
    DE A unique step-by-step visual approach to numerology, how to assess
    DE characters and compatibility from names and birth dates.
    **
    IB 1898295395
    BI SPIRAL BOUND
    AU PRICE, ROBIN
    BC ELX
    CO UK
    PD 19961231
    RP 15.75
    RI 15.75
    RE 15.75
    PU ENGLISH EXPERIENCE
    YP 1996
    SR BRAIN FRIENDLY RESOURCES
    TI CONVERSATION 2: STUDENT TALK
    EA 9781898295396
    RF R
    GC C01
    **
    [/SIZE]

    Between the ** is each books data.

    When I import into Access it takes the info as it is. But what I would like is to have the 2 letters at the start of each line as the colum headers, e.g. AU means Author, so people can search by author etc.

    But at the mo, when it get's imported it looks just like it is in the text file, which I can really do anything with.

    If anyone has any ideas, or has a book website, I would be very greatful for your help, as I'm really stuck on this one.

    Thanks for your help

    Best Wishes

    Laura
     
    purplepixi, Dec 12, 2005 IP
  2. dave487

    dave487 Peon

    Messages:
    701
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If you can upload this text file to your website you can then use the fopen function in php to parse the file line by line.

    the function then would put the value of each line into the the correct field in your database based on what the first 2 characters are on that line.

    http://uk.php.net/fopen

    Hope this helps.
     
    dave487, Dec 12, 2005 IP
  3. daniah

    daniah Well-Known Member

    Messages:
    1,092
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    138
    #3
    I can write a php script which will parse the txt file and upload the contents to a Mysql database. Cost $75. PM me if you are interested.
     
    daniah, Dec 12, 2005 IP
  4. l234244

    l234244 Peon

    Messages:
    1,225
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I agree with Dave and daniah, you need a script to work with that amount of data. $75 or 10 days copy and pasting, I know which I would go with.
     
    l234244, Dec 16, 2005 IP
  5. sufyaaan

    sufyaaan Banned

    Messages:
    218
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I have bolded my favorite word in your post... :D
     
    sufyaaan, Dec 17, 2005 IP
  6. daniah

    daniah Well-Known Member

    Messages:
    1,092
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    138
    #6
    oh well I meant upload the txt file and load the contents to a Mysql database...if that makes you happy
     
    daniah, Dec 18, 2005 IP