Example #1
0
function process_spreadsheet($path)
{
    $keys = array();
    $newArray = array();
    $data = csv_to_array($path, ',');
    // Set number of elements (minus 1 because we shift off the first row)
    $count = count($data) - 1;
    //Use first row for names
    $labels = array_shift($data);
    foreach ($labels as $label) {
        $keys[] = $label;
    }
    // Add Ids, just in case we want them later
    $keys[] = 'id';
    for ($i = 0; $i < $count; $i++) {
        $data[$i][] = $i;
    }
    // Bring it all together
    for ($j = 0; $j < $count; $j++) {
        $d = array_combine($keys, $data[$j]);
        if (!is_empty_str($d["ID"])) {
            //            $newArray[$j] = $d;
            $newArray[$d["ID"]] = $d;
        }
    }
    return $newArray;
}
Example #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     function csv_to_array($filename = '', $delimiter = ',')
     {
         if (!file_exists($filename) || !is_readable($filename)) {
             return FALSE;
         }
         $header = NULL;
         $data = array();
         if (($handle = fopen($filename, 'r')) !== FALSE) {
             while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) {
                 if (!$header) {
                     $header = $row;
                 } else {
                     $data[] = array_combine($header, $row);
                 }
             }
             fclose($handle);
         }
         return $data;
     }
     $csvFile = public_path() . '/csvs/categories.csv';
     $datas = csv_to_array($csvFile);
     DB::table('categories')->delete();
     foreach ($datas as $data) {
         Categories::create($data);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     function csv_to_array($filename = '', $delimiter = ',')
     {
         if (!file_exists($filename) || !is_readable($filename)) {
             return FALSE;
         }
         $header = NULL;
         $data = array();
         if (($handle = fopen($filename, 'r')) !== FALSE) {
             while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) {
                 if (!$header) {
                     $header = $row;
                 } else {
                     $data[] = array_combine($header, $row);
                 }
             }
             fclose($handle);
         }
         return $data;
     }
     $csvFile = public_path() . '/exams.csv';
     $areas = csv_to_array($csvFile);
     DB::table('exams')->insert($areas);
 }
function print_hotels()
{
    $hotels = csv_to_array('hotels.csv');
    foreach ($hotels as $hotel) {
        #var_dump($hotel);
        $shorttel = str_replace(' ', '', $hotel["tel"]);
        $img = isset($hotel["img"]) && $hotel["img"] ? $hotel["img"] : 'generic_hotel.jpg';
        echo <<<EOL
<div class='hotel'>
  <a class='imga' href="img/hotels/{$img}">
  <img src="img/hotels/_{$img}" />
  </a>
  <h3>{$hotel["name"]}</h3>

  <div class="address">
  {$hotel["street"]}<br>
  {$hotel["loc"]}
  </div>

  <a class="web" href="{$hotel["url"]}">{$hotel["url"]}</a>
  <a class="mail" href="mailto:{$hotel["email"]}">contact</a>
  <a class="tel" href="tel:{$shorttel}">{$hotel["tel"]}</a>
</div>
EOL;
    }
}
Example #5
0
 protected function csv_to_array($data)
 {
     if (defined('STRICT_TYPES') && CAMEL_CASE == '1') {
         return (array) self::parameters(['data' => DT::TEXT])->call(__FUNCTION__)->with($data)->returning(DT::TYPE_ARRAY);
     } else {
         return csv_to_array($data);
     }
 }
Example #6
0
File: func.php Project: efoft/studi
function pre_import($filename)
{
    $results = array();
    foreach (csv_to_array($filename, FALSE) as $csv) {
        #var_dump($csv);
        $results[] = array('firstname' => $csv[1], 'lastname' => $csv[2], 'phone' => $csv[3], 'email' => $csv[4]);
    }
    return $results;
}
Example #7
0
 public function createBits($csv)
 {
     #load csv to an array
     $local = csv_to_array($csv);
     foreach ($local as $singleBit) {
         $container = array_values($singleBit);
         $T = new BitWord();
         $T->setWord(trim($container[0]));
         $T->setDefinition(trim($container[1]));
         $T->setSynonym(trim($container[2]));
         #ADD INITIALIZED BIT TO bit property array
         $this->bits[] = $T;
         unset($T);
     }
 }
Example #8
0
function uploadFiletoDB($UserFileName)
{
    $TransactionArray = array();
    $TblName = TableName;
    $FileName = $_FILES[$UserFileName]['name'];
    $FileServerName = $_FILES[$UserFileName]['tmp_name'];
    $CSVFIle = 'transactionTable.csv';
    $CSVDelimiter = ';';
    $ValidRecordswrited = 0;
    $InvalidRecords = 0;
    if (getFileExtension($FileName) == 'xlsx') {
        convertXLStoCSV($FileServerName, $CSVFIle);
        $CSVDelimiter = ',';
    } else {
        $CSVFIle = $FileServerName;
    }
    $TransactionArray = csv_to_array($CSVFIle, $CSVDelimiter);
    if (sizeof($TransactionArray) > 100000) {
        echo '<br>';
        echo "Error - file rows cont is to much";
        return false;
    }
    $Connection = mysql_connect(ServerName, UserName, Password);
    $db_selected = mysql_select_db(DBName, $Connection);
    if (!$Connection) {
        die("Connection failed: " . mysql_error());
    }
    foreach ($TransactionArray as $Line) {
        if (checkTransactionRecord($Line)) {
            $Request = "INSERT INTO {$TblName}(`Account`, `Description`, `CurrencyCode`, `Ammount`) VALUES ('{$Line['Account']}','{$Line['Description']}','{$Line['CurrencyCode']}',{$Line['Amount']})";
            $result = mysql_query($Request);
            if (!$result) {
                echo 'Query error: ' . mysql_error();
            } else {
                $ValidRecordswrited++;
            }
        } else {
            $InvalidRecords++;
        }
    }
    mysql_close($Connection);
    echo '<br> <br>';
    echo "Valid records writed to DataBase: {$ValidRecordswrited}";
    echo '<br>';
    echo "Invalid records count: {$InvalidRecords}";
}
Example #9
0
<?php

$sDestinationFile = __DIR__ . '/../languages.php';
$aSourcesFiles = array('languages' => __DIR__ . '/Languages.csv', 'directionalities' => __DIR__ . '/LanguagesDirectionality.csv', 'scripts' => __DIR__ . '/LanguagesScripts.csv');
$aData = csv_to_array($aSourcesFiles['languages']);
$aDirectionalitiesSrc = csv_to_array($aSourcesFiles['directionalities']);
foreach ($aDirectionalitiesSrc as $sLanguageCode => $aDirectionality) {
    if (isset($aData[$sLanguageCode])) {
        $aData[$sLanguageCode]['Directionality'] = $aDirectionality['Directionality'];
    }
}
$aScriptsSrc = csv_to_array($aSourcesFiles['scripts']);
foreach ($aScriptsSrc as $sLanguageCode => $aScript) {
    if (isset($aData[$sLanguageCode])) {
        $aData[$sLanguageCode]['Script'] = $aScript['Script'];
    }
}
file_put_contents($sDestinationFile, "<?php\n\nreturn " . var_export($aData, true) . ";\n");
/**
 * Convert a comma separated file into an associated array.
 * The first row should contain the array keys.
 *
 * Example:
 *
 * @param string $sFilename Path to the CSV file
 * @param string $sDelimiter The separator used in the file
 * @return array
 * @link http://gist.github.com/385876
 * @author Jay Williams <http://myd3.com/>
 * @copyright Copyright (c) 2010, Jay Williams
 * @license http://www.opensource.org/licenses/mit-license.php MIT License
Example #10
0
function csv_to_array($filename = '/Users/emmanuel.manyike/Desktop/use.csv', $delimiter = ';')
{
    if (!file_exists($filename) || !is_readable($filename)) {
        echo "file does not exist\n";
    }
    $header = NULL;
    $data = array();
    if (($handle = fopen($filename, 'r')) !== FALSE) {
        echo "file exist\n";
        $handle2 = fopen('/private/var/www/spree.local/htdocs/app/code/local/Touchlab/SpreeDbUpdates/data/spreedbupdates_setup/data-upgrade-0.1.52-0.1.53.php', 'w');
        $counter = 0;
        while ($row = fgets($handle)) {
            $row = trim($row, "\r\n");
            $sizedata = explode(';', $row);
            $string = "UPDATE eav_attribute_option SET sort_order = {$sizedata['1']} WHERE option_id = {$sizedata['0']}; " . PHP_EOL;
            if ($handle2) {
                fwrite($handle2, $string);
            } else {
                echo "inside else";
                echo $string;
            }
        }
        echo "done bro";
        fclose($handle2);
        fclose($handle);
    }
    return $data;
}
//UPDATE eav_attribute_option SET sort_order = 0 WHERE option_id = 832;
$csvData = csv_to_array();
Example #11
0
<?php

require_once "functions.php";
// Get array from CSV
$str = stripslashes($_POST["csv"]);
$data = csv_to_array($str);
// Find row with the most columns
$col_count = 0;
foreach ($data as $row) {
    $col_count = count($row) > $col_count ? count($row) : $col_count;
}
?>
<div class="fog"></div>

<div class="edit_table" style="display:none;">

	<div class="modal_window_header" class="clearfix"> 
		Edit Table
		<a class="close_modal" href=""></a> 
	</div>
	
	<div class="edit_table_content">
		<table>
			
			<tr>
				<td class="row_selector blank"></td>
				<?php 
for ($col = 0; $col < $col_count; $col++) {
    ?>
<td class="column_selector"><?php 
    echo num_to_chars($col + 1);
<?php 
$news = csv_to_array('data/science_advisory_committee.csv');
// sort by date, newest on top
function compare_lastname($a, $b)
{
    return strnatcmp($a['last_name'], $b['last_name']);
}
usort($news, 'compare_lastname');
echo "<ul>\n";
foreach ($news as $v) {
    echo "  <li>{$v['first_name']} {$v['last_name']}</li>\n";
}
echo "</ul>\n";
 <?php 
require_once "./includes/db_connection.php";
require_once "./includes/cvsProcess.php";
?>

<?php 
$the_array[] = csv_to_array('transactions.csv');
foreach ($the_array as $array_row) {
    foreach ($array_row as $array_element) {
        //echo print_r($array_element);
        //    echo $array_element['Date'];
        //    echo "<br>";
        $trans_date = $array_element['Date'];
        $original_description = addslashes($array_element['Original Description']);
        $amount = $array_element['Amount'];
        $transaction_type = $array_element['Transaction Type'];
        $trans_date = date("Y-m-d", strtotime($trans_date));
        $query = "INSERT INTO mintImport (trans_date, original_description, amount, transaction_type)\n    VALUES ('{$trans_date}', '{$original_description}', '{$amount}', '{$transaction_type}')";
        $result = mysqli_query($connection, $query);
        if (!$result) {
            die("Database query failed.");
        }
    }
}
#print_r($_GET)
#echo $deviceName;
# ?deviceName=devicenamed&sensorName=sensorNamed&sensorReading=32
// on récupère la liste des images contenues dans le répertoire des tiles
$tiles = find_all_files($TILES_DIR);
$tilesImg = array();
foreach ($tiles as $index => $filename) {
    if ($filename == $IMG_SPACE) {
        unset($tiles[$index]);
    } else {
        $tilesImg[] = imagecreatefromstring(file_get_contents($TILES_DIR . $filename));
    }
}
// on charge l'image contenant les espaces
$spaceImg = imagecreatefromstring(file_get_contents($TILES_DIR . $IMG_SPACE));
// on récupère le contenu du fichier CSV
$fileContent = file_get_contents($FILE_FACES);
// on extrait le contenu CSV dans un tableau
$tabFaces = csv_to_array($fileContent, $CSV_DELIMITER);
// génération des images
// on va calculer les dimensions des images pour chaque face
$scale = $TILE_HEIGHT / $TILE_HEIGHT_M;
foreach ($tabFaces as $index => $faceInfos) {
    // HEIGHT
    $faceInfos['img_height'] = $TILE_HEIGHT;
    // WIDTH : conversion en fonction des mètres
    $faceInfos['img_width'] = round($faceInfos['length'] * $scale);
    // FILE NAME
    $faceInfos['filename'] = $faceInfos['code'] . "_" . $faceInfos['face'] . ".png";
    // on calcule le nombre de tiles qu'il faut mettre dans l'image
    $nbTiles = floor($faceInfos['img_width'] / $TILE_WIDTH);
    // on calcule le nombre d'espaces
    if ($nbTiles > 0) {
        $nbSpaces = $nbTiles - 1;
Example #15
0
        foreach ($gcdata as $k) {
            $p[] = $count == 0 ? '"' . $k . '"' : $k;
            $count++;
        }
        $chart_data[] = "[" . implode(",", $p) . "]";
    }
    foreach ($gheader as $d) {
        $header_data[] = '"' . $d . '"';
    }
    $header_data = "[" . implode(",", $header_data) . "]";
    $chart_data = implode(",", $chart_data);
    $full_chart_data = "[" . $header_data . "," . $chart_data . "]";
    return $full_chart_data;
}
$DataFile = $_SERVER['DOCUMENT_ROOT'] . "/googlechart/tread.csv";
$GChartData = csv_to_array($DataFile);
$full_chart_data = BuildDataTable($GChartData['data'], $GChartData['header']);
?>

<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
  google.load("visualization", "1", {packages:["corechart"]});
  google.setOnLoadCallback(drawChart);
  function drawChart() {
    var data = google.visualization.arrayToDataTable(<?php 
echo $full_chart_data;
?>
);

    var options = {
        title: '',
Example #16
0
function load_countries_from_csv($file_name)
{
    $tmp = csv_to_array($file_name);
    $cntryarr = array();
    foreach ($tmp as $line) {
        $cntryarr[$line["iso"]] = $line["name_en"];
    }
    unset($tmp);
    return $cntryarr;
}
							$( document ).ready(function() {
									$("your-circle").circliful({
										animationStep: 5,
										foregroundBorderWidth: 5,
										backgroundBorderWidth: 15,
										percent:' . $value['Percent'] . '});
							});
						</script>';
    if ($value['Percent'] <= 50) {
        echo "<tr>";
        echo "<td><img src ='images/CapstoneImages/{$value['Team One']}.png' style = 'opacity:0.4;'>";
        echo "{$value['Team One']}</td>";
        echo "<td>{$value['Percent']}%</td>";
        echo "<td><img src ='images/CapstoneImages/{$value['Team Two']}.png'>";
        echo "{$value['Team Two']}</td>";
        echo '</tr>';
        //echo $donut;
    } else {
        echo "<tr>";
        echo "<td><img src ='images/CapstoneImages/{$value['Team One']}.png'>";
        echo "{$value['Team One']}</td>";
        echo "<td>{$value['Percent']}%</td>";
        echo "<td><img src ='images/CapstoneImages/{$value['Team Two']}.png' style = 'opacity:0.4;'></td>";
        echo "<td>{$value['Team Two']}</td>";
        echo '</tr>';
    }
}
$gameData = csv_to_array('final_results_.csv');
$team_one = $_POST['Home'];
$team_two = $_POST['Away'];
showResults($gameData, $team_one, $team_two);
Example #18
0
 * 
 * Example:
 * 
 * @param string $filename Path to the CSV file
 * @param string $delimiter The separator used in the file
 * @return array
 */
function csv_to_array($filename = '', $delimiter = ',')
{
    if (!file_exists($filename) || !is_readable($filename)) {
        return FALSE;
    }
    $header = NULL;
    $data = array();
    if (($handle = fopen($filename, 'r')) !== FALSE) {
        while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) {
            if (!$header) {
                $header = $row;
            } else {
                $data[] = array_combine($header, $row);
            }
        }
        fclose($handle);
    }
    return $data;
}
/**
 * Example
 */
print_r(csv_to_array('example.csv'));
         foreach ($p->{'Value'} as $v) {
             $var = sprintf("%s", $v->attributes()->{'Var'});
             $val = sprintf("%s", $v);
             $uom = sprintf("%s", $v->attributes()->{'Unit'});
             if (!array_key_exists($var, $data) && is_numeric($val)) {
                 $data[$var] = array('val' => array($val), 't' => array($t), 'uom' => $uom, 'lyr' => $name);
             } else {
                 if (!isset($_REQUEST['nowOnly']) && is_numeric($val)) {
                     array_push($data[$var]['val'], $val);
                     array_push($data[$var]['t'], $t);
                 }
             }
         }
     }
 } else {
     $csv = csv_to_array($dataString);
     for ($i = 0; $i < count($csv); $i++) {
         // assume that the min time represents all hits
         preg_match("/(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)T(\\d\\d):(\\d\\d):(\\d\\d)Z/", $csv[$i]['time'], $a);
         $t = mktime($a[4], $a[5], $a[6], $a[2], $a[3], $a[1]);
         if (isset($_REQUEST['nowOnly'])) {
             if (!array_key_exists('time', $data) || $t < $data['time']) {
                 $data['time'] = $t;
             }
         }
         foreach (array_keys($csv[$i]) as $vStr) {
             if ($vStr != 'time') {
                 preg_match("/(.*)\\[(.*)\\]/", $vStr, $a);
                 $var = $a[1];
                 $val = $csv[$i][$vStr];
                 $uom = $a[2];
<?php

require_once 'init.php';
if (!$_FILES || empty($_FILES['backlog_file'])) {
    ?>
	<form action="" method="post" enctype="multipart/form-data">
		<label>
			Select CSV File
			<input type="file" name="backlog_file" />
		</label>
		<button type="submit">Upload</button>
	</form><?php 
} else {
    $backlog = csv_to_array($_FILES['backlog_file']['tmp_name']);
    save_array_to_file($backlog, 'uploads/backlog-current.php');
}
Example #21
0
<?php

/**
* @link http://gist.github.com/385876
*/
$ddl = csv_to_array("input.csv");
$currentTable = "";
foreach ($ddl as $attribute) {
    if ($currentTable != $attribute['table_name']) {
        if ($currentTable != "") {
            echo ");</br></br>";
        }
        $currentTable = $attribute['table_name'];
        echo "CREATE TABLE {$currentTable}(";
        echo "</br>";
    }
    $attributeName = $attribute['Attribute'];
    $dataType = $attribute['sql_type'];
    $isKey = " ";
    if ($dataType == 'varchar') {
        $dataType = "varchar(50)";
    }
    if ($attribute['Key Type'] == "Primary") {
        $isKey = " Primary Key";
    }
    echo "\t{$attributeName} \t\t{$dataType}{$isKey}\t\tNOT NULL,";
    echo "</br>";
}
echo ");";
echo "</br>";
// echo "<pre>";
Example #22
0
/**
* $resout       is the residue table file created by writeMulticritChart
* $rscc_file    is the formatted rscc file
* $multi_table  is the multi crit chart (to get the prequel)
* $outfile      is the name out file that this function will write to
* $raw_rscc_out is the raw rscc file
*/
function writeHorizontalChart($resout, $rscc_file, $multi_table, $outfile, $rscc_prequel_out)
{
    $startTime = time();
    // get prequel
    $in = fopen($multi_table, 'rb');
    clearstatcache();
    $data = fread($in, filesize($multi_table));
    fclose($in);
    $multi = mpUnserialize($data);
    $prequel = $multi['prequel'];
    $in = fopen($resout, 'rb');
    clearstatcache();
    $data = fread($in, filesize($resout));
    fclose($in);
    $res_table = mpUnserialize($data);
    $rscc_table = csv_to_array($rscc_file, ',');
    // {{{ integrate rscc into $res_table annd set $horiz_table
    foreach ($rscc_table as $info) {
        if (!array_key_exists($info['res_id'], $res_table)) {
            continue;
        }
        $res_table[$info['res_id']]['worst_b_bb'] = $info['worst_b_bb'];
        $res_table[$info['res_id']]['worst_cc_bb'] = $info['worst_cc_bb'];
        $res_table[$info['res_id']]['worst_2fo-fc_bb'] = $info['worst_2fo-fc_bb'];
        $res_table[$info['res_id']]['worst_b_sc'] = $info['worst_b_sc'];
        $res_table[$info['res_id']]['worst_cc_sc'] = $info['worst_cc_sc'];
        $res_table[$info['res_id']]['worst_2fo-fc_sc'] = $info['worst_2fo-fc_sc'];
    }
    // params = bb Density, sc Density, Clash, Ramachandran, Rotamer,
    //          cB deviation, Bond length, Bond angle');
    $mp_params = array('bb Density', 'sc Density', 'Clash', 'Ramachandran', 'Rotamer', 'cB deviation', 'Bond length', 'Bond angle');
    $horiz_table = array();
    // create array for horizontal table
    foreach ($mp_params as $param) {
        $horiz_table[$param] = array();
        foreach ($res_table as $resid => $info) {
            if (substr($resid, -3) != "HOH") {
                $horiz_table[$param][$resid] = array();
            }
        }
    }
    // }}}
    // {{{ set parameters
    // {{{ set bb Density
    foreach ($horiz_table['bb Density'] as $resid => $info) {
        $horiz_table['bb Density'][$resid]['value'] = array();
        $horiz_table['bb Density'][$resid]['value']['2fo-fc'] = $res_table[$resid]['worst_2fo-fc_bb'];
        $horiz_table['bb Density'][$resid]['value']['cc'] = $res_table[$resid]['worst_cc_bb'];
        $s = "<center>Backbone Density<br />cc : ";
        $s .= $horiz_table['bb Density'][$resid]['value']['cc'] . "<br />2Fo-Fc : ";
        $s .= $horiz_table['bb Density'][$resid]['value']['2fo-fc'] . "</center>";
        $horiz_table['bb Density'][$resid]['html'] = $s;
        $img = "no_out.png";
        if ($horiz_table['bb Density'][$resid]['value']['2fo-fc'] < 1.1 || $horiz_table['bb Density'][$resid]['value']['cc'] < 0.75) {
            $img = "density_outA.png";
        }
        if ($horiz_table['bb Density'][$resid]['value']['2fo-fc'] < 0.8 || $horiz_table['bb Density'][$resid]['value']['cc'] < 0.6) {
            $img = "density_outB.png";
        }
        $horiz_table['bb Density'][$resid]['image'] = $img;
    }
    // }}}
    // {{{ set sc Density
    foreach ($horiz_table['sc Density'] as $resid => $info) {
        $horiz_table['sc Density'][$resid]['value'] = array();
        $horiz_table['sc Density'][$resid]['value']['2fo-fc'] = $res_table[$resid]['worst_2fo-fc_sc'];
        $horiz_table['sc Density'][$resid]['value']['cc'] = $res_table[$resid]['worst_cc_sc'];
        $s = "<center>Backbone Density<br />cc : ";
        $s .= $horiz_table['sc Density'][$resid]['value']['cc'] . "<br />2Fo-Fc : ";
        $s .= $horiz_table['sc Density'][$resid]['value']['2fo-fc'] . "</center>";
        $horiz_table['sc Density'][$resid]['html'] = $s;
        $img = "no_out.png";
        if ($horiz_table['sc Density'][$resid]['value']['2fo-fc'] < 1.1 || $horiz_table['sc Density'][$resid]['value']['cc'] < 0.75) {
            $img = "density_outA.png";
        }
        if ($horiz_table['sc Density'][$resid]['value']['2fo-fc'] < 0.8 || $horiz_table['sc Density'][$resid]['value']['cc'] < 0.6) {
            $img = "density_outB.png";
        }
        if (endsWith($resid, "GLY") || endsWith($resid, "gly")) {
            $horiz_table['sc Density'][$resid]['value']['2fo-fc'] = '-';
            $horiz_table['sc Density'][$resid]['value']['cc'] = '-';
            $img = "null.png";
        }
        $horiz_table['sc Density'][$resid]['image'] = $img;
    }
    // }}}
    // {{{ set Clash
    foreach ($horiz_table['Clash'] as $resid => $info) {
        if ($res_table[$resid]['clash_isbad']) {
            $horiz_table['Clash'][$resid]['value'] = $res_table[$resid]['clash_val'];
            // $info['value'] = $res_table[$resid]['clash_val'];
            $horiz_table['Clash'][$resid]['html'] = $res_table[$resid]['clash'];
            if ($horiz_table['Clash'][$resid]['value'] < 0.7) {
                $img = "clash_outA.png";
            } elseif ($horiz_table['Clash'][$resid]['value'] < 1.0) {
                $img = "clash_outC.png";
            } else {
                $img = "clash_outD.png";
            }
            $horiz_table['Clash'][$resid]['image'] = $img;
        } else {
            $horiz_table['Clash'][$resid]['value'] = 0;
            $horiz_table['Clash'][$resid]['html'] = "<center>-</center>";
            $horiz_table['Clash'][$resid]['image'] = "no_out.png";
        }
    }
    // }}}
    // {{{ set Ramachandran
    foreach ($horiz_table['Ramachandran'] as $resid => $info) {
        $horiz_table['Ramachandran'][$resid]['value'] = $res_table[$resid]['rama_val'];
        $horiz_table['Ramachandran'][$resid]['html'] = $res_table[$resid]['rama'];
        if ($res_table[$resid]['rama_isbad']) {
            $img = "rama_out.png";
        } else {
            $img = "no_out.png";
        }
        $horiz_table['Ramachandran'][$resid]['image'] = $img;
    }
    // }}}
    // {{{ set Rotamer
    foreach ($horiz_table['Rotamer'] as $resid => $info) {
        $horiz_table['Rotamer'][$resid]['value'] = $res_table[$resid]['rota_val'];
        $horiz_table['Rotamer'][$resid]['html'] = $res_table[$resid]['rota'];
        if ($res_table[$resid]['rota_isbad']) {
            $img = "rotamer_out.png";
        } else {
            $img = "no_out.png";
        }
        if (endsWith($resid, "GLY") || endsWith($resid, "gly")) {
            $img = "null.png";
        }
        $horiz_table['Rotamer'][$resid]['image'] = $img;
    }
    // }}}
    // {{{ set cB deviation
    foreach ($horiz_table['cB deviation'] as $resid => $info) {
        if ($res_table[$resid]['cbdev_isbad']) {
            $horiz_table['cB deviation'][$resid]['value'] = $res_table[$resid]['cbdev_val'];
            $horiz_table['cB deviation'][$resid]['html'] = $res_table[$resid]['cbdev'];
            $horiz_table['cB deviation'][$resid]['image'] = "cBd_out.png";
        } else {
            $horiz_table['cB deviation'][$resid]['value'] = 0;
            $horiz_table['cB deviation'][$resid]['html'] = "<center>-</center>";
            $horiz_table['cB deviation'][$resid]['image'] = "no_out.png";
        }
    }
    // }}}
    // {{{ set Bond length
    foreach ($horiz_table['Bond length'] as $resid => $info) {
        if ($res_table[$resid]['bbonds_isbad']) {
            $horiz_table['Bond length'][$resid]['value'] = $res_table[$resid]['bbonds_isbad'];
            $horiz_table['Bond length'][$resid]['html'] = $res_table[$resid]['bbonds'];
            $horiz_table['Bond length'][$resid]['image'] = "bl_out.png";
        } else {
            $horiz_table['Bond length'][$resid]['value'] = 0;
            $horiz_table['Bond length'][$resid]['html'] = "<center>-</center>";
            $horiz_table['Bond length'][$resid]['image'] = "no_out.png";
        }
    }
    // }}}
    // {{{ set Bond angle
    foreach ($horiz_table['Bond angle'] as $resid => $info) {
        if ($res_table[$resid]['bangles_isbad']) {
            $horiz_table['Bond angle'][$resid]['value'] = $res_table[$resid]['bangles_isbad'];
            $horiz_table['Bond angle'][$resid]['html'] = $res_table[$resid]['bangles'];
            $horiz_table['Bond angle'][$resid]['image'] = "ba_out.png";
        } else {
            $horiz_table['Bond angle'][$resid]['value'] = 0;
            $horiz_table['Bond angle'][$resid]['html'] = "<center>-</center>";
            $horiz_table['Bond angle'][$resid]['image'] = "no_out.png";
        }
    }
    // }}}
    // }}}
    $table1 = array();
    $table1['prequel'] = $prequel;
    $table1['rscc_prequel'] = getRsccPrequel($horiz_table, $rscc_prequel_out);
    $table1['horiz_table'] = $horiz_table;
    $out = fopen($outfile, 'wb');
    fwrite($out, mpSerialize($table1));
    fclose($out);
    echo "Formatting horizontal chart table took " . (time() - $startTime) . " seconds\n";
}
Example #23
0
    if (($handle = fopen($filename, 'r')) !== FALSE) {
        while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) {
            // if(!$header)
            //     $header = $row;
            // else
            //     $data[] = array_combine($header, $row);
            $data[] = $row;
        }
        fclose($handle);
    }
    return $data;
}
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
set_time_limit(30);
$filelist = getenv("DOCUMENT_ROOT") . "/test/ts_list.csv";
$carlist = csv_to_array($filelist);
echo "<pre>";
if (CModule::IncludeModule("iblock")) {
    $el = new CIBlockElement();
    foreach ($carlist as $cardata) {
        //print_r( $cardata );
        $PRODUCT_ID = null;
        $PROP = array("71" => "12.08.2015", "66" => 2073, "70" => 12, "72" => 700, "73" => preg_replace("/\\s/", "", $cardata[0]), "67" => preg_replace("/\\s/", "", $cardata[1]), "76" => preg_replace("/\\s/", "", $cardata[2]), "75" => 6488);
        $arLoadProductArray = array("MODIFIED_BY" => 1, "IBLOCK_SECTION_ID" => false, "IBLOCK_ID" => IBLOCK_SK_CHASSIS_ID, "PROPERTY_VALUES" => $PROP, "NAME" => empty($PROP["76"]) ? $PROP["73"] : $PROP["76"], "ACTIVE" => "Y");
        // print_r( $arLoadProductArray );
        if ($PRODUCT_ID = $el->Add($arLoadProductArray)) {
            echo "New ID: " . $PRODUCT_ID;
        } else {
            echo "Error: " . $el->LAST_ERROR;
            print_r($arLoadProductArray);
            echo "<hr/>";
                $prepareData[$header[$n]] = $items[$n];
            }
            $data[] = $prepareData;
        }
    }
    return $data;
}
//This scraper holds modern synths.
//Delete existing data
$info = scraperwiki::table_info($name = "swdata");
if (!empty($info)) {
    scraperwiki::sqliteexecute("DELETE FROM swdata");
    //Truncate the table before adding new results
}
$modernSynthData = file_get_contents("https://docs.google.com/spreadsheet/pub?hl=en_US&hl=en_US&key=0Aht1e-sbjyvPdHJmaUIzTEctZl8tc2tVWjdjYnFpOGc&single=true&gid=0&output=csv");
$modernSynthData = csv_to_array($modernSynthData);
//print_r($modernSynthData);
$synths = array();
$counter = 0;
foreach ($modernSynthData as $synth) {
    if (!empty($synth)) {
        $synths[$counter]['manufacturer'] = $synth['Manufacturer'];
        $synths[$counter]['name'] = $synth['Synth Name'];
        $synths[$counter]['url'] = $synth['Source URL'];
        $synths[$counter]['images'] = $synth['Images'];
        $counter++;
    }
}
//print_r($synths);
if (!empty($synths)) {
    scraperwiki::save_var('total_results', count($synths));
Example #25
0
        $final_data[] = str_getcsv($parse_it, ',', '"');
    }
    return $final_data;
}
//----------------------------------------------------------------------------------------|
//--------------------uncomment this stuff when you want to insert into MySQL!!-----------|
//----------------------------------------------------------------------------------------|
//connect to mysql, which we'll be using to keep track of everything.
//$mysqli  = new mysqli('127.0.0.1', 'root', '', 'test', '3306');
/* check connection */
//if (mysqli_connect_errno()) {
//    printf("Connect failed: %s\n", mysqli_connect_error());
//    exit();
//}
//put the path to your csv here.
$csv = csv_to_array('backlinks.csv');
use SEOstats\Services as SEOstats;
// Create a new SEOstats instance.
$seostats = new \SEOstats\SEOstats();
//--------------------------------------------------------------------------|
//----------echo HTML, in case we just want to take a quick look------------|
//--------------------------------------------------------------------------|
echo "<div class='row'><h1>External Backlinks Stats</h1></div>";
foreach ($csv as $row) {
    try {
        $url = "http://www." . $row[0];
        //get rid of that comma
        $link_num = str_replace(",", "", $row[1]);
        $linked_pages = $row[2];
        // Bind the URL to the current SEOstats instance.
        if ($seostats->setUrl($url)) {
Example #26
0
</table>
<?php 
if (isset($_POST["submit"])) {
    if (isset($_FILES["file"])) {
        if ($_FILES["file"]["error"] > 0) {
        } else {
            //if file already exists
            if (file_exists("upload/" . $_FILES["file"]["name"])) {
                echo $_FILES["file"]["name"] . " already exists. ";
            } else {
                //Store file in directory "upload" with the name of "uploaded_file.txt"
                $storagename = "uploaded_file.xls";
                move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $storagename);
                print 'Import successfully!';
            }
        }
    } else {
        echo "No file selected <br />";
    }
}
print parse_excel_to_table("upload/" . $storagename);
$profiles = csv_to_array("upload/" . $storagename);
for ($i = 0; $i < count($profiles); $i++) {
    $username = $profiles[$i];
    $user = user_load_from_name($username);
    $uid = $user['User_ID'];
    if ($user['Role_ID'] == 2) {
        delete_course_user($cid, $uid);
        create_course_user($cid, $uid);
    }
}
/*
Link to edit the map:
    http://umap.openstreetmap.fr/en/map/anonymous-edit/78775%3AQazSqz7NxNtECK5cabetfRbeKfU
*/
?>

<iframe width="100%" height="600px" frameBorder="0" src="http://umap.openstreetmap.fr/en/map/hotels-near-irchel_78775?scaleControl=true&miniMap=false&scrollWheelZoom=false&zoomControl=true&allowEdit=false&moreControl=false&datalayersControl=false&onLoadPanel=undefined&captionBar=false"></iframe>
<p>
    <a class="small" href="http://umap.openstreetmap.fr/en/map/hotels-near-irchel_78775">
        See full screen
    </a>
</p>


<?php 
$hotels = csv_to_array('data/hotels.csv');
foreach ($hotels as $hotel) {
    #var_dump($hotel);
    if (!$hotel['show'] == "Y") {
        continue;
    }
    $shorttel = str_replace(' ', '', $hotel['tel']);
    $img = isset($hotel['img']) && $hotel['img'] ? $hotel['img'] : 'generic_hotel.jpg';
    echo "<div class='hotel bordered'>\n";
    echo "  <a class='imga' href='img/hotels/{$img}'>\n";
    echo "    <img src='img/hotels/_{$img}' />\n";
    if ($hotel['aircon'] === 'Y') {
        echo "    <img title='has air conditioning' class='ico x1' src='img/aircon.png' />\n";
    }
    if ($hotel['wifi'] === 'Y') {
        echo "    <img title='has free wifi' class='ico x2' src='img/wifi.png' />\n";
Example #28
0
 	$eid = sql_real_escape_string($_POST["eventId"]);
 	$uid = sql_real_escape_string($_POST["userId"]);*/
 if (!empty($_POST["deleteItems"])) {
     delete_pool_contents();
 } else {
     $tmp_csv_file = $_FILES['uploadedfile']['tmp_name'];
     //$ext = pathinfo($_FILES['uploadedfile']['name'], PATHINFO_EXTENSION);
     //$target_path = "/var/www/backend/parti-pics/$uid.$ext";
     ////$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
     if (!empty($_POST["workbookId"])) {
         $tmp_csv_file = "/tmp/" . uniqid(time(0));
         //			download_file("https://docs.google.com/spreadsheet/ccc?key={$_POST["workbookId"]}&gid={$_POST["sheetId"]}&output=csv", $tmp_csv_file, "/tmp/" . uniqid(time(0)));
         download_file("https://docs.google.com/spreadsheets/d/{$_POST["workbookId"]}/export?format=csv&id={$_POST["workbookId"]}&gid={$_POST["sheetId"]}", $tmp_csv_file, "/tmp/" . uniqid(time(0)));
         //file_put_contents($tmp_csv_file, file_get_contents("https://docs.google.com/spreadsheet/ccc?key={$_POST["workbookId"]}&gid={$_POST["sheetId"]}&output=csv"));
     }
     $csv_data = csv_to_array($tmp_csv_file);
     if ($csv_data) {
         //if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)){
         $check = TRUE;
         if (count($csv_data) > 0) {
             foreach ($REQUIRED_FILEDS as $field) {
                 if (!isset($csv_data[0][$field])) {
                     $check = FALSE;
                     break;
                 }
             }
         }
         if ($check) {
             if (!empty($_POST["deleteFirst"])) {
                 delete_pool_contents();
             }
Example #29
0
    die;
}
function csv_to_array($file = '', $length = 0, $delimiter = ';')
{
    $header = NULL;
    $data = array();
    if (($handle = fopen($file, 'r')) !== FALSE) {
        while (($row = fgetcsv($handle, $length, $delimiter)) !== FALSE) {
            if (!$header) {
                $header = $row;
            } else {
                $data[] = array_combine($header, $row);
            }
        }
        fclose($handle);
    }
    return $data;
}
include_once 'include/Webservices/Create.php';
foreach (csv_to_array($file) as $row) {
    //print_r($row);
    try {
        $row = vtws_create('Accounts', $row, $current_user);
        echo "Organisation: " . $row['id'] . PHP_EOL;
    } catch (WebServiceException $ex) {
        $msg = $ex->getMessage();
        $msg .= print_r($row, true) . "\n";
        error_log($msg, 3, $file . "-error.log");
        echo $msg;
    }
}
 public function Get_record_file_handle()
 {
     //<--this function helps to find and return clculating records data
     $csvStored_data = "";
     $start_date = $this->get_date_period_start();
     $end_date = $this->get_date_period_ends();
     $month_start = $start_date[1] - 1;
     //<--special arrangement for yahoo finance data (0 -> january)
     $month_ends = $end_date[1] - 1;
     //<--special arrangement for yahoo finance data (0 -> january)
     $file = 'http://ichart.yahoo.com/table.csv?s=' . $this->company_symbol . '&a=' . $month_start . '&b=' . $start_date[2] . '&c=' . $start_date[0] . '&d=' . $month_ends . '&e=' . $end_date[2] . '&f=' . $end_date[0] . '&g=' . $this->interval . '&ignore=.csv';
     $stored_data = CompanyData::get_last_updated_record($this->company_symbol);
     //<-- this function finds the data from database
     if ($stored_data) {
         if (date("Y-m-d", strtotime($stored_data->updated)) < date("Y-m-d", time()) || $stored_data->accuracy < $this->precision) {
             $csvStored_data = csv_to_array($file, ',');
             //<----exploring CSV file
             if (count($csvStored_data) > 4) {
                 //<--checks for the genuinity
                 $company_id = Company::find_company_id_company_symbol($this->company_symbol);
                 $prediction = CompanyData::where('comp_id_fk', '=', $company_id)->delete();
                 $company = CompanyData::create(array('comp_id_fk' => $company_id, 'csvdata' => serialize($csvStored_data), 'updated' => date("Y-m-d H:i:s", time()), 'accuracy' => $this->precision));
             }
         } else {
             $csvStored_data = unserialize($stored_data->csvdata);
         }
         $this->company_description = $stored_data->description;
         $this->company_address = $stored_data->address;
     } else {
         $company = new Company();
         $company->company_name = trim($this->company_name);
         $this->company_description = get_Company_data($this->company_symbol, 'desci');
         get_Company_logo($this->company_symbol);
         //<--fuction used to copy image
         $company->description = $this->company_description;
         $company->company_symbol = trim($this->company_symbol);
         $csvStored_data = csv_to_array($file, ',');
         //<----exploring CSV file
         if (count($csvStored_data) > 4) {
             //<--checks for the genuinity
             $company = Company::create(array('company_name' => trim($this->company_name), 'company_description' => get_Company_data($this->company_symbol, 'desci'), 'description' => $this->company_description, 'company_symbol' => trim($this->company_symbol)));
             if ($company) {
                 if ($csvStored_data) {
                     get_Company_logo($this->company_symbol);
                     //<--fuction used to copy image
                 }
                 $CompanyData = CompanyData::create(array('comp_id_fk' => trim($company->id), 'csvdata' => serialize($csvStored_data), 'updated' => date("Y-m-d H:i:s", time()), 'accuracy' => $this->precision));
                 $predict_data = Prediction::create(array('comp_id_fk' => trim($company->id)));
             }
         }
     }
     return !empty($csvStored_data) ? $csvStored_data : false;
 }