Contents
Login Register Wishes Forum About
Language Reference » Dataset functions » importFromCSV
Help topics
Latest updates
4574d  replaceImageMapTitle
4574d  replaceImageMapValues
4574d  createFunctionSerie
4574d  setAbsicssaPosition
4574d  negateValues
Toolbox
  Download as PDF
  Print this page
  Share this page
  Create an account
  Feed the updates!
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.

Column numbering is starting from 0.

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)));
Last updated on 12/14/2010 
by Jean-Damien 
Linked resources
  There is no linked topic yet.
Community comments
  No comments have been posted yet.
© 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. 415 users have registered. This page has been rendered in 0,19 seconds. Wiki revision 1.37.