Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 358777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T12:19:54+00:00 2026-05-12T12:19:54+00:00

On a http website, I have loads of csv files stored which chronological naming

  • 0

On a http website, I have loads of csv files stored which chronological naming scheme. I wrote a PHP program (running on localhost) to programmatically generate each files name using date functions and use file_get_contents() to write the files locally.

I have tested for a limited range of dates and am able to get the files (each around 1.3M). However, over a large period (say, 3 years, with a file for each weekday), would this cause a timeout? Or is it not a timeout because the response has not actually stopped?

Here’s the code for reference:

<?php
$start_date = '08SEP2009';
$check_date = $start_date;
$end_date = '14SEP2009';

function getNextDate() {
    global $check_date;
    $check_date = date("dMY", strtotime ("+1 day", strtotime($check_date))); //get next date
    return $check_date;
}   

function downloadFiles() {
    $cur_date = getNextDate();

    $url = "http://nse-india.com/content/historical/DERIVATIVES/YYYY/MMM/foDDMMMYYYYbhav.csv"; //this represents the naming scheme for the CSVs
    while(strcasecmp($cur_date, $end_date)) {
        $year = date("Y", strtotime($cur_date)); //get year (2004)
        $month = strtoupper(date("M", strtotime($cur_date))); //get month (SEP)
        $day = date("d", strtotime($cur_date)); //get day of month (09)

        $filename = str_replace('DD', $day, str_replace('MMM', $month, str_replace('YYYY', $year, $url))); //construct file name for new date
        $content = @file_get_contents($filename); 
        $localfile = array_reverse(explode("/", $filename)); //reverse array so that filename.csv comes as first element
        $localfile = $localfile[0]; //filename to store locally

        $handle = fopen($localfile, "w");
        fwrite($handle, $content); //save file locally
        fclose($handle);
    }
}

downloadFiles();
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T12:19:54+00:00Added an answer on May 12, 2026 at 12:19 pm

    PHP scripts have a configurable timeout period. Generally this is set to 30 seconds by default in the php.ini file, configurable with the max_execution_time setting. You would be well-advised to call set_time_limit(0) (see set_time_limit()) to remove this limit.

    Other than that, there is no specific reason why your script should time out. You might want to remove the @ from the file_get_contents() call however, and handle any triggered errors yourself, just to facilitate the process. That is a very likely place that you’re going to see issues if any arise.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have an asp.net website http://www.site.com . This web app is also running on
I wish to download information from the website http://revigo.irb.hr/ which have an interactive menu.
I have some code running on my website which will detect if a div
I have built a website and when my users load up http://info.salemgolfclub.org/Account/Logon the username
I have this website http://wedessertmore.com that has some forms popup when you click on
So lets say I have the following scenario. http://website.com:8080 and http://website.com:8080/demo Is there any
I have (from the sed website http://sed.sourceforge.net/sed1line.txt ) this one-liner: sed -e '/./{H;$!d;}' -e
I have website based on Umbraco 5. I have installed contact form plugin (http://cultivjupitercontact.codeplex.com/).
I'm developing this website: http://parkoura.tk/a/sandbox/ I am using an ajax navigation. I have a
I have set up a website here: http://liamwli.co.uk/ggsim On the bottom, there are 2

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.