My favorites | Sign in
Project Logo
                
Search
for

Simple data access object for csv files in php5.

by Kazuyoshi Tlacaelel.

Some features

Cells

  1. fillCell cell value filler
  2. getCell cell fetcher
  3. hasCell checks if a coordinate is valid

Headers

  1. countHeaders header counter
  2. createHeaders header creator
  3. getHeaders header fetcher
  4. setHeaders header injector

Columns

  1. appendColumn column appender
  2. fillColumn collumn data injector
  3. getColumn column fetcher
  4. hasColumn column existance checker
  5. removeColumn column remover
  6. walkColumn column walker

Must see

  1. __construct data load initialize
  2. connect header and row relationship builder
  3. getRawArray raw data as array
  4. isSymmetric data length/symmetry checker
  5. load csv file loader
  6. settings settings alterator
  7. symmetrize all rows length equalizer
  8. walkGrid grid walker

Rows

  1. appendRow row appender
  2. countRows row counter
  3. fillRow fillRow
  4. getAsymmetricRows asymmetric data fetcher
  5. getRow row fetcher
  6. getRows multiple row fetcher
  7. hasRow row existance checker
  8. removeRow row remover
  9. walkRow row walker
Updated Dec 18, 2008 by kazu....@gmail.com
fillCell  

Method:fillCell

cell value filler

replaces the value of a specific cell

sample of a csv file "my_cool.csv"

name,age,skill
john,13,knows magic
tanaka,8,makes sushi
jose,5,dances salsa

php implementation

$csv = new File_CSV_DataSource;

// load the csv file
$csv->load('my_cool.csv');

// find out if the given coordinate is valid
if($csv->hasCell(1, 1)) {

// if so grab that cell and dump it
var_export($csv->getCell(1, 1));       // '8'

// replace the value of that cell
$csv->fillCell(1, 1, 'new value');  // true

// output the new value of the cell
var_export($csv->getCell(1, 1));       // 'new value'

}

now lets try to grab the whole row

// show the whole row
var_export($csv->getRow(1));

standard output

array (
0 => 'tanaka',
1 => 'new value',
2 => 'makes sushi',
)
  1. Argument integer $x the row to fetch
  2. Argument integer $y the column to fetch
  3. Argument mixed $value the value to fill the cell with

Sign in to add a comment
Hosted by Google Code