Innovative Tech Consulting

Contact UsView Openings

How to Read Tab Delimited File Using PHP

Basic example to read tab delimited file

$fp = fopen('mydata.csv', 'r');

while ( !feof($fp) )
{
$line = fgets($fp, 2048);

$someCondition = someConditionToDetermineTabOrComma();

$delimiter = $someCondition ? "," : "\t";
$data = str_getcsv($line, $delimiter);

doSomethingWithData($data);
}

fclose($fp);

Drupal 7 Test module

Hello World Module for Drupal 7

  • mymodule.module file. Path: /sites/default/modules/mymodule

'Hello World Test',
'page callback' => 'say_hello_world',
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
);

return $items;
}

function say_hello_world() {
$vars = array();
$vars['type']="ul";
$vars['title'] = "";
$vars['attributes']=array("");
$vars['items'][0]="This is a simple proof of concept module";

return theme_item_list($vars);
}

  • >mymodule.info file. path: sites/default/modules/mymodule

name = mymodule
description = test proof of concept module
package = public-action
version = VERSION
core = 7.x
files[] = mymodule.module

; Information added by drupal.org packaging script on 2010-03-21
version = "7.0-alpha3"
project = "drupal"
datestamp = "1269192313"

How to Use Cluetip Module with views in Drupal7

Cluetip Module Implementation

  • Download Module from here: http://drupal.org/project/cluetip
  • Upload it into sites/all/modules.
  • Download Cluetip Library from here: https://github.com/kswedberg/jquery-cluetip
  • Upload LIbrary to sites/all/libraries and rename it cluetip
  • Add drupal_add_library(‘cluetip’, ‘cluetip’); into template.php