![]() |
Language Reference » Dataset functions » importFromCSV
|
|
Latest updates
Toolbox
Google AdSense
|
importFromCSV - Load data from a CSV (or similar) file This function allow you to populate your data series by retrieving data from a CSV (or any kind of characters separated text files).It is possible to set extra parameters with the $Option array. To learn more about this please read the Format array guide.
Calling this function
importFromCSV($FileName,$Option="");Where : FileName is the path to the file to load (can be local or remote).
Option is an array containing some extra parameters. Customisation array - Extra parameters It is possible to give extra parameters to the CSV engine : The delimiter can be set with Delimiter.
If your file contains column headers then set GotHeader to TRUE.
If you want to skip columns, provide them through the SkipColumns array.
If the CSV does not contains an header, serie names will be based on the DefaultSerieName start string. Sample script #1 Assuming we have the following CSV file (delimited by comma) : ![]() /* pChart library inclusions */ include("../class/pData.class.php"); /* Create the pData object with some random values*/ $MyData = new pData(); /* Import the data from a CSV file */ $MyData->importFromCSV("resources/dataset.txt"); Sample script #2 Assuming we have the following CSV file (delimited by comma) with an header: ![]() /* pChart library inclusions */ include("../class/pData.class.php"); /* Create the pData object with some random values*/ $MyData = new pData(); /* Import the data from a CSV file */ $MyData->importFromCSV("resources/dataset.txt",array("GotHeader"=>TRUE)); Sample script #3 Assuming we have the following CSV file (delimited by comma) with an header where we want to skip column 1 (Temperature) : ![]() /* pChart library inclusions */ include("../class/pData.class.php"); /* Create the pData object with some random values*/ $MyData = new pData(); /* Import the data from a CSV file */ $MyData->importFromCSV("resources/dataset.txt",array("GotHeader"=>TRUE,"SkipColumns"=>array(1)));
© Copyrights
Components used on this web site : Famfamfam icons has been made by Mark James, Rounded corners lite has been coded by Cameron Cooke and Tim Hutchison, SyntaxHighlighter has
been written by Alex Gorbatchev. pChart and this web site have been created by Jean-Damien POGOLOTTI. This documentation contains 185 pages and 56 comments. 413 users have registered.
This page has been rendered in 0,02 seconds. Wiki revision 1.37.
|