Ejemplo n.º 1
0
function read_worksheet($out, $file, $options = array())
{
    $ext = pathinfo($file, PATHINFO_EXTENSION);
    if (isset($options["read"]) && $options["read"] != $ext) {
        fputs(STDERR, "Warning: The file extension was ignored to adopt {$options["read"]}.\n");
        $ext = $options["read"];
    }
    switch (strtolower($ext)) {
        case "raw":
            $in = fopen($file, "r");
            while (($line = fgets($in)) !== false) {
                fputs($out, $line);
            }
            fclose($in);
            break;
        case "csv":
            $options["delimiter"] = ",";
            read_csv($out, $file, $options);
            break;
        case "tsv":
            $options["delimiter"] = "\t";
            read_csv($out, $file, $options);
            break;
        case "xlsx":
            read_excel($out, $file, $options);
            break;
        case "json":
            read_json($out, $file, $options);
            break;
        case "yml":
        case "yaml":
            read_yaml($out, $file, $options);
            break;
        case "xml":
            read_xml($out, $file, $options);
            break;
        default:
            print "Error[{$ext}]: No reader is available.\n";
            break;
    }
    return;
}
Ejemplo n.º 2
0
if ($_REQUEST['url'] == '' || $_REQUEST['key'] == '' || $_REQUEST['project_id'] == '' || $_REQUEST['collection_id'] == '') {
    include '../loginForm.php';
} else {
    //echo "<body onload=\"interfaceCode()\">";
    $url = $_REQUEST['url'] == '' ? 'http://ibl.mdanderson.org/central' : $_REQUEST['url'];
    $key = $_REQUEST['key'] == '' ? 'serpoetaesermaisalto' : $_REQUEST['key'];
    $project_id = $_REQUEST['project_id'] == '' ? '530' : $_REQUEST['project_id'];
    $collection_id = $_REQUEST['collection_id'];
    $file = $_FILES['file']['name'];
    #$file=	'test';
    if (!@copy($_FILES['file']['tmp_name'], $file)) {
        if (!@move_uploaded_file($_FILES['file']['tmp_name'], $file)) {
            echo "File was NOT imported. Please <a href='" . $_SERVER['PHP-SELF'] . "'>try again</a>.";
        }
    }
    $data = read_excel($file);
    $lines = array_filter($data);
    #The line of literal rules will be calculated based on the first fully numeric, largest line
    #Bystepping PHP, pass every cell to javascript
    $rules = array_filter($data[0]);
    $ruleString = implode(',', $rules);
    #get all rules
    $s3ql = compact('url', 'key');
    $s3ql['from'] = 'rules';
    $s3ql['where']['project_id'] = $project_id;
    $Prules = S3DBcall($s3ql);
    $Prules = $Prules[1];
    $subjects = array();
    $objects = array();
    $ruleIds = array();
    $subjectAsObjects = array();
Ejemplo n.º 3
0
function save_excel($target_file)
{
    global $locations;
    global $duplicateLoc;
    global $cityId;
    global $city;
    read_excel($target_file);
    $db = pdoConnect();
    $query = "INSERT INTO `locality` (`cityID`,`localityText`) VALUES ";
    for ($i = 0; $i < count($locations); $i++) {
        if ($i > 0) {
            $query .= ",";
        }
        $query .= "(" . $cityId . " , '" . $locations[$i][0] . "')";
    }
    $stmt = $db->prepare($query);
    if ($stmt->execute()) {
        echo "<div class=\"alert alert-success\"> Localities are successfully added for city \"" . $city . "\" </div>";
    } else {
        echo "<div class=\"alert alert-danger\"> Errors while saving localities ! !<br>Please contact admin</div>";
    }
    unlink($target_file);
}
Ejemplo n.º 4
0
<?php

include 'S3QLgoodies.php';
$cells = read_excel('DFT_test.txt');
$header = $cells[0];
##Now that excel has been read, make the connection to S3DB
$project_id = '530';
$url = 'http://ibl.mdanderson.org/edu';
$key = 'olafarrusco';
##Find ALL collections
list($collections, $collection_names, $collection_ids) = findCollections($url, $key, $project_id);
#Find ALL the rules
list($rules, $ruleSubs, $ruleVerbs, $ruleObjs, $ruleIds) = findRules($url, $key, $project_id);
##INSERTING ANTIBIOGRAM FIRST
#Now, for each rule, find all those that concern antibiotic, this means find the rules where the subject_id is the same as the one for collection_id of antibiotic
#Find antibiogram collection id
$atbCollection = $collection_ids[array_search('antibiogram database', $collection_names)];
#Find sample collection id
$splCollection = $collection_ids[array_search('sample', $collection_names)];
#Find isolate collection id
$isoltCollection = $collection_ids[array_search('isolate', $collection_names)];
#Find rules of antibiogram
list($atbRule, $atbVerb, $atbObj) = findRulesBySubject($atbCollection, $rules);
$atbList = array_unique($atbObj);
#Find rules of Sample
list($splRule, $splVerb, $splObj) = findRulesBySubject($splCollection, $rules);
#Find rules of Isolate
list($isltRule, $isltVerb, $isltObj) = findRulesBySubject($isoltCollection, $rules);
#Now find the equivalent data on Excel
#Find the cols with data on antibiotics
$atbCols = array_intersect($header, $atbList);