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 Coder
    Join Date
    Jun 2011
    Posts
    16
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Create CSV on server

    In Brno, 29.01.2012

    Hello everybody,

    i really need your help with one issue. I need any php which create .csv file on server every 2 minutes and fill in some data.

    I need to track some stocks to .csv file. This file will be replaced every two minutes by new one (values will be changed).

    for example:

    1. I need to track 3 stocks: Google, Apple, Deutche Bank, i have solved how to get prices. I only need any php to create .csv file like this:

      A1: "company", "price", "quantity in portfolio" and so on
      B1: Google, 580.00, 13, ...
      C1: Apple, 440.87, 23, ....
      D1: Deutche Bank, 44.44, 130, ...
      E1: next stock, price, quantity, ...
      ....
    2. It would be perfect if that .csv file would be saved in special folder on my server.


    I would really apreciate every help, thank you in advance!

    Stefan alias "Scharfheimlich"

  • #2
    Regular Coder
    Join Date
    Jan 2012
    Posts
    271
    Thanks
    2
    Thanked 65 Times in 65 Posts
    csv files are pretty easy to make

    PHP Code:
    $csvData 'A1: "company", "price", "quantity in portfolio" and so on\n
    B1: Google, 580.00, 13, ...\n
    C1: Apple, 440.87, 23, ....\n
    D1: Deutche Bank, 44.44, 130, ...\n
    E1: next stock, price, quantity, ...'
    ;
    $dumpFile 'my_csv_file.csv';

    $fp fopen($dumpFile'w');
    fwrite($fp$csvData);
    fclose($fp); 
    then run it every 2 minutes with crontab

  • Users who have thanked jmj001 for this post:

    Scharfheimlich (01-29-2012)

  • #3
    New Coder
    Join Date
    Jun 2011
    Posts
    16
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by jmj001 View Post
    csv files are pretty easy to make

    PHP Code:
    $csvData 'A1: "company", "price", "quantity in portfolio" and so on\n
    B1: Google, 580.00, 13, ...\n
    C1: Apple, 440.87, 23, ....\n
    D1: Deutche Bank, 44.44, 130, ...\n
    E1: next stock, price, quantity, ...'
    ;
    $dumpFile 'my_csv_file.csv';

    $fp fopen($dumpFile'w');
    fwrite($fp$csvData);
    fclose($fp); 
    then run it every 2 minutes with crontab
    Thank you so much. I would very appreciate if you would give me also that crontab please. I am just an economist, i tried to run it using help from this page (http://adminschoice.com/crontab-quick-reference), but i was not successful...

    Again really thank you!

  • #4
    Regular Coder
    Join Date
    Jan 2012
    Posts
    271
    Thanks
    2
    Thanked 65 Times in 65 Posts
    you need to create a php script that you can manually run with your browser every however long...

    then, when that is working and creating the csv file you are trying to make...

    you can then automate the process by having the server process 'crontab' automatically run that php file for you...

    but first you have to make the file/script to do the work you need done..

    some pointers....
    http://www.cyberciti.biz/faq/howto-s...pt-as-cronjob/
    http://www.wallpaperama.com/forums/h...ble-t5657.html
    http://support.modwest.com/content/5...t-on-cron.html

  • Users who have thanked jmj001 for this post:

    Scharfheimlich (01-29-2012)


  •  

    Posting Permissions

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