Results 1 to 12 of 12

Thread: PHP, mySQL, CSV

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2002
    Location
    Singapore
    Posts
    32

    PHP, mySQL, CSV

    Can I use PHP to create a script that takes a CSV file and writes it to a mySQL database?

    Also, wha'ts the limit to the DB size? Cos i have about 1800 records to add in.

    Thanks!
    C you, C me

  2. #2
    Fanatic Member Gimlin's Avatar
    Join Date
    Dec 2001
    Location
    Hell
    Posts
    734
    3398 per table

  3. #3
    Lively Member scoutt's Avatar
    Join Date
    Aug 2002
    Posts
    84
    3398 per table? a DB can hold 4 TB of info. so I don't think you are limited to a certain size in a table. and 1800 records is small.

    also Gimlin I had 20,000 rows in one table.
    Just Imagine what you can do with the power of php.

    257 Tutorials and counting.
    529 Snippets and growing.

    Add yours today @
    SnippetLibrary.com

  4. #4
    Fanatic Member Gimlin's Avatar
    Join Date
    Dec 2001
    Location
    Hell
    Posts
    734
    Ooops I ment 3398 columns

  5. #5
    Lively Member scoutt's Avatar
    Join Date
    Aug 2002
    Posts
    84
    ahh hehe that makes sense.
    Just Imagine what you can do with the power of php.

    257 Tutorials and counting.
    529 Snippets and growing.

    Add yours today @
    SnippetLibrary.com

  6. #6

    Thread Starter
    Member
    Join Date
    Jul 2002
    Location
    Singapore
    Posts
    32
    ok, thanks for the size of DB thing

    so, is it possible to read in a CSV file and convert it to mySQL using PHP or any other means? thanks!
    C you, C me

  7. #7
    Lively Member scoutt's Avatar
    Join Date
    Aug 2002
    Posts
    84
    you can read any type of file and parse it through php and insert it into the database.
    Just Imagine what you can do with the power of php.

    257 Tutorials and counting.
    529 Snippets and growing.

    Add yours today @
    SnippetLibrary.com

  8. #8

    Thread Starter
    Member
    Join Date
    Jul 2002
    Location
    Singapore
    Posts
    32
    got any sample code to share? a bit new at this

    suppose my file is :

    "data1", "data2", "data3"
    "data1", "data2", "data3"

    where each field is within " " and seperated by commas and each new line is a new record.

    How do i use the string functions to extract out each bit of data from within the " "?

    thanks!
    C you, C me

  9. #9
    Lively Member scoutt's Avatar
    Join Date
    Aug 2002
    Posts
    84
    Just Imagine what you can do with the power of php.

    257 Tutorials and counting.
    529 Snippets and growing.

    Add yours today @
    SnippetLibrary.com

  10. #10

    Thread Starter
    Member
    Join Date
    Jul 2002
    Location
    Singapore
    Posts
    32
    Originally posted by scoutt
    http://www.snippetlibrary.com/viewht...d=12&siteid=62

    same idea.
    thanks! but if i use

    explode (',',$fileread[$i]);

    then if my data has a comma in it, it will also be stripped into an array. Cos in one of the fields, there are commas within the data block

    Thanks!
    C you, C me

  11. #11
    Lively Member scoutt's Avatar
    Join Date
    Aug 2002
    Posts
    84
    then I would change the comma to something else. if you are using a CSV then all commas are delimiters and they show the seperation between fields. that's what CSV means "Comma Separated Values text file format (ASCII)"

    if you have commas in with your data then you better switch it or is is not a CSV.
    Just Imagine what you can do with the power of php.

    257 Tutorials and counting.
    529 Snippets and growing.

    Add yours today @
    SnippetLibrary.com

  12. #12
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    just split each line by

    ", "

    then, hopefully you will not get any problems with that

Posting Permissions

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



Click Here to Expand Forum to Full Width