0

I want to access a CSV file behind a Javascript object for my LOAD DATA INFILE function.

e.g. the "Download Max" button on this page, https://www.barchart.com/futures/quotes/Znh18/price-history/historical OR The "Download a Spreadsheet" button on this page, http://quotes.wsj.com/bond/BX/TMUBMUSD10Y/historical-prices#

This is my code

...
$csvfile = '\'/home4/cascaderange/public_html/00_test/znh18_180208.csv\'';
$cminfile = 'LOAD DATA LOCAL INFILE '
            .$csvfile.' 
            replace INTO TABLE TABLE04 FIELDS TERMINATED by \',\' 
            IGNORE 1 LINES;';

mysqli_query($conn,$cminfile) or die(mysqli_error());
...

Thanks!

Ivan Mamontov
  • 2,874
  • 1
  • 19
  • 30
  • Can you please say what the actual problem your having is. – Nigel Ren Feb 10 '18 at 08:14
  • Sorry. the LOAD DATA INFILE function needs a file, $csvfile above. To get another CSV file I just change the link, e.g. 'http://mooremarkettrends.com/00_test/znh18_180208.csv'. However, the files at barchart.com and wsj.com, above, do not have direct links because the user must click a JS button. So, how do I write the link to get the file from barchart.com or wsj.com? thx – user2299779 Feb 10 '18 at 18:09

1 Answers1

0

I think you can use openCSV library for this. I did'nt use before . Try this link

happy_coding
  • 1,064
  • 1
  • 13
  • 24