php - auto zip download from url -
i need help 1 snippet of code has me ready explode, involving automatically downloaded zip folder external url, containing single txt file, upload mysql database, finish project i've been working on 5 years.
the short version need daily text file url:
http://batstrading.com/market_data/shortsales/2014/06/byxxshvol20140620.txt.zip-dl?mkt=byx
i have tried everything, in hundred combinations. on occasions no errors occurred, there no txt files created nor uploaded db , permissions set 777
zip_open, zip_read, zip_entry_open, zip_entry_read, fgets, fopens, file_get_contents
the long version valid url is:
function getbatstxtfile($batszipurlfile, $batszoutputfile) { $batszipurl="http://batstrading.com/market_data/shortsales/2014/06/byxxshvol20140620.txt.zip-dl?mkt=byx"; file_get_contents($batszipurl); $batstxtzipfile=zip_open($batszipurl); $batstxtzipfile=zip_read($batszipurl); $batstxtfile = zip_entry_open($batstxtzipfile; $batstxt = zip_entry_read($batstxtfile); $batstxt = str_replace("date|symbol|short volume|total volume|market center", "",$batstxt); $batstxt = str_replace("|", ",", $batstxt); $batstxt = trim($batstxt); file_put_contents($batszoutputfile, $batstxt); zip_entry_close($batstxtfile); zip_close($batszipurl); } i have 3000000 lines of code, 10,000 failed scripts, , need have life back...is .txt file retrieved. give thanks in advance.
here go
<?php // fetch zip file $zip = file_get_contents('http://batstrading.com/market_data/shortsales/2014/06/byxxshvol20140620.txt.zip-dl?mkt=byx'); file_put_contents('bats.zip', $zip); // read specific file zip archive $txt = file_get_contents('zip://bats.zip#byxxshvol20140620.txt'); // text transformations $txt = str_replace('date|symbol|short volume|total volume|market center', '', $txt); $txt = str_replace('|', ',', $txt); $txt = trim($txt); // output modified txt file file_put_contents('out.txt', $txt); php mysql zip
No comments:
Post a Comment