Dr. Arne Jachens

Set up the Raspberry Pi

no warranty for any of the provided information

Script to read in structured data, where the first line is expected to contain the names of the data columns.

From dicrectory $path the file $fname is read in. The data should be in columns which are separated by $delimiter.

The result $data is an array with column names of raw data as array keys.

<?php 
/* published under GPL www.gnu.org/licenses/gpl.html */
function readNamedData($fname,$path,$delimiter){
  $fname=sprintf("%s%s", $path, $fname);
  if (file_exists($fname)) {
    $fid = fopen($fname, "r");
    $line = fgets( $fid, 2048 ); #headerline
    $line=str_replace(" #","",trim($line));
    $fieldNames=explode($delimiter,$line);
    $NoVars=count($fieldNames);
    $line = fgets( $fid, 2048 );
    $n=-1;
    while(!feof($fid)){
    if($line[0]!=" #"){
      $n++;
      /* change format of numbers */
      $line=str_replace(",",".",$line);
      $values=explode($delimiter,$line);
      #echo $fname. "<br>";
      #print_r($fieldNames);echo "<br>";
      #print_r($values);echo"<br>";
      #exit(1);
      $time[$n]=trim($values[0]);
      echo $line. "<br>";
      for($m=0;$m<$NoVars;$m++){
	$data[$fieldNames[$m]][$n]=trim($values[$m]);
      } #m
      } #fi
      $line = fgets( $fid, 2048 );
    } #n
    fclose($fid);
  }else{
    printf("FILE ".$fname." DOES NOT EXIST!\N");
  }
  return $data;
}
?>

python

1HvcControl.py
2HvcHCSR04ultrasonic.py
3HvcMain.py
4HvcMotorDriver.py
5HvcOneWire.py
6HvcOperationMode.py
7HvcRaw2phys.py
8HvcReadSPI.py
9HvcSendI2C.py
10HvcSetGPIO.py
11HvcTables.py
12HvcWeather.py
13makeDoc.py

php

1HV_Admin_Login.php
2HV_colorMap.php
3HV_composeH2Oplot.php
4HV_config.php
5HV_H2Olevel.php
6HV_readOperationState.php
7HV_restart.php
8HV_serviceLog.php
9HV_setParameters.php
10HV_showHouse.php
11HV_showLog.php
12HV_showWeatherForecast.php
13HV_TempCal.php
14index.php
15readFilenames.php
16readNamedData.php

Der gesamte Sourcecode darf gemäß GNU General Public License weiterverbreitet werden.