Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Breaking an 800 record .csv file into individual .csv files.

    I have a website that allows customers to see dynamic quotes in about a thousand equity securities.

    the quotes are generated in a spreadsheet on my local machine, then copied to individual .csv files with the following information:

    Symbol,Bid,Ask,BidSize,AskSize
    ABCDF,9.95.10.05,500,200

    the .csv files are then ftp'd up to the server where the php script on the web page pulls data from the .csv files and from the mysql database for display to the customer.

    the problem is that it takes like 5 minutes to move the individual files from my side to the server side. that's not exactly dynamic. on the other hand, it takes less than a second to upload one .csv file with all the data.

    what i'd like to find out is whether or not it's possible to use fgetcsv to turn each record of the large .csv file into an array, and then use fputcsv to copy the individual arrays into individual .csv files.

    also, if it is possible, where would i put the .php file with the script to accomplish that?

  • #2
    eak
    eak is offline
    Regular Coder eak's Avatar
    Join Date
    Jun 2002
    Location
    Nashville, TN
    Posts
    354
    Thanks
    0
    Thanked 26 Times in 26 Posts
    You could have an extra column in your big csv file that indicates what section/category the data belongs in. When parsing the big csv, just look at that column to determine where to save the data.

    Why are you using csv's and mysql? Why not just mysql?
    eak | "Doing a good deed is like wetting your pants; every one can see the results, but only you can feel the warmth."

  • #3
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks very much for the look!

    I'm using both because a good bit of the data is static so it's a matter of not having 30 or 40 fields per record on the spreadsheet, and minimizing what needs to be uploaded.

    do you mean putting the path or just the file name the extra column?

    for example: NSRGY,42.93,43.13,200,200,/PRICES/NSRGY.CSV ?

    sorry if i'm not following.

    thanks again.

  • #4
    eak
    eak is offline
    Regular Coder eak's Avatar
    Join Date
    Jun 2002
    Location
    Nashville, TN
    Posts
    354
    Thanks
    0
    Thanked 26 Times in 26 Posts
    You could put the path in the extra column, but it doesn't really matter.
    It just needs to be an identifier that your parsing script can check for.

    Its up to you to decide.
    eak | "Doing a good deed is like wetting your pants; every one can see the results, but only you can feel the warmth."


  •  

    Tags for this Thread

    Posting Permissions

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