当前位置: 首页>>代码示例>>PHP>>正文


PHP readCSV函数代码示例

本文整理汇总了PHP中readCSV函数的典型用法代码示例。如果您正苦于以下问题:PHP readCSV函数的具体用法?PHP readCSV怎么用?PHP readCSV使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了readCSV函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: main

function main()
{
    $archivo = 'csvDelitos.csv';
    if ($_POST["action"] == "upload") {
        if (copy($_FILES['archivo']['tmp_name'], "files/txt/" . $archivo)) {
            $status = "Archivo subido: <b>" . $archivo . "</b>";
            $bStatus = True;
        } else {
            $status = "Error al subir el archivo";
        }
    }
    $listaValores = readCSV($archivo);
    $_SESSION['fecha'] = $listaValores[0];
    //array
    $_SESSION['valores'] = $listaValores[1];
    //array
    $fileFechas = createFile('fechas', $listaValores[0]);
    //creamos archivo de fechas
    $fileValores = createFile('valores', $listaValores[1]);
    //creamos archivo de valores
    //echo '<br/>'.implodeFecha();
    //echo '<br/>'.implodeValores();
    //echo '<br/>'.countValores();
    //echo '<br/>'.callPython($fileValores);
    //echo '<br/>'.callNormalizar($fileValores);
    $_SESSION['normalizar'] = callNormalizar($fileValores);
    //String
    unlink('files/txt/' . $archivo);
    //eliminamos el archivo creado
    createCSV($archivo, $listaValores[2]);
}
开发者ID:rafaellopezgtz,项目名称:neurored,代码行数:31,代码来源:index.php

示例2: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     //        $this->comment(PHP_EOL.Inspiring::quote().PHP_EOL);
     foreach (readCSV() as $key => $person) {
         $this->sendMail($person, $key);
     }
 }
开发者ID:alerj,项目名称:aloalerjsite,代码行数:12,代码来源:Inspire.php

示例3: getRegion

function getRegion($region = "", $json)
{
    $jsonObj = json_decode($json);
    //die(print_r($jsonObj));
    $regionsArr = array();
    // 0 => array ( "code" => "gr", name => "Greece" )
    $airports = readCSV();
    //print_r($airports);
    foreach ($airports as $k => $v) {
        if ($v[region][code] == $region) {
            $flag = true;
            foreach ($regionsArr as $k2 => $v2) {
                if ($v2[code] == $v[country][code]) {
                    $flag = false;
                    break;
                }
            }
            if ($flag) {
                $regionsArr[] = array("code" => $v[country][code], "name" => $v[country][name]);
            }
        }
    }
    $regionJsonObj = new stdClass();
    //print_r($regionsArr);
    foreach ($regionsArr as $k3 => $v3) {
        $flag = false;
        foreach ($jsonObj->pathes as $id => $obj2) {
            if (mb_strtolower($v3[name], 'UTF-8') == mb_strtolower($obj2->name, 'UTF-8')) {
                $flag = true;
                $regValObj = new stdClass();
                $innerObj = new stdClass();
                $myId = $v3[code];
                $innerObj->path = $obj2->path;
                $innerObj->name = $obj2->name;
                $regionJsonObj->pathes->{$myId} = $innerObj;
            }
        }
        if (!$flag) {
            echo "{$v3['name']} not found\n";
        }
    }
    echo "\n\n ---------------------------------- \n\n";
    foreach ($jsonObj->pathes as $id => $obj2) {
        echo "{$obj2->name} \n";
    }
    print_r(json_encode($regionJsonObj));
}
开发者ID:bogiesoft,项目名称:hotelexpert,代码行数:47,代码来源:functions.php

示例4: writeFile

function writeFile($path, $pemisah)
{
    global $jenisdata;
    $dir = $path;
    $ext = explode('.', basename($_FILES['filex']['name']));
    $ext = $ext[count($ext) - 1];
    $ext = strtolower($ext);
    if ($ext == 'csv') {
        $path = $dir . "/" . date('ymd') . "." . $ext;
        @unlink($path);
        try {
            if (move_uploaded_file($_FILES['filex']['tmp_name'], $path)) {
                $x = readCSV($path, $pemisah);
                simpanData($x, $jenisdata);
            }
        } catch (Exception $e) {
            echo "<script>alert(\"Error Writing File" . addslashes($e->getMessage()) . "\");</script>";
        }
    } else {
        echo "<script>alert('Filetype not support" . basename($_FILES['filex']['name']) . "__" . $path . "');</script>";
    }
}
开发者ID:halimc17,项目名称:magsys,代码行数:22,代码来源:bgt_slave_uploadData.php

示例5: main

function main($dir, $colname, $reload, $csvonly)
{
    $xlsx_njs = "./js/node_modules/xlsx/bin/xlsx.njs";
    echo $dir;
    $d = dir($dir);
    while (false !== ($entry = $d->read())) {
        if (!is_dir($dir . $entry) && endsWith($entry, ".xls")) {
            $csvFile = "{$entry}.csv";
            if (file_exists($dir . $csvFile)) {
                if ($reload == 1) {
                    echo "{$csvFile} already exist. Reload it!\n";
                    // process generated CSV
                    readCSV($dir, $csvFile, $colname);
                } else {
                    echo "{$csvFile} already exist. Skip it!\n";
                }
            } else {
                echo "working on {$csvFile}...\n";
                $snames = getSheetNames($xlsx_njs, $dir, $entry);
                foreach ($snames as $key => $sname) {
                    if ($key == 0) {
                        $sysStr = "{$xlsx_njs} '{$dir}/{$entry}' {$sname} > '{$dir}/{$csvFile}'";
                    } else {
                        $sysStr = "{$xlsx_njs} '{$dir}/{$entry}' {$sname} >> '{$dir}/{$csvFile}'";
                    }
                    echo "Writing CSV for {$sname} \n";
                    system($sysStr);
                }
                if ($csvonly) {
                    continue;
                }
                // process generated CSV
                readCSV($dir, $csvFile, $colname);
            }
        }
    }
    $d->close();
}
开发者ID:hunkim,项目名称:kproperty,代码行数:38,代码来源:csv2mongo.php

示例6: __construct

 public function __construct()
 {
     $this->users = readCSV('users.csv');
 }
开发者ID:homer4hire247,项目名称:is218-midterm,代码行数:4,代码来源:user.php

示例7: readCSV

<?php

function readCSV($file)
{
    $f = file($file);
    foreach ($f as $k) {
        $csv[] = explode("\t", $k);
    }
    return $csv;
}
$lines = readCSV("data/objectcodes.tsv");
foreach ($lines as $line) {
    echo "<tr class= \"result\">\n";
    foreach ($line as $item) {
        echo "<td>" . $item . "</td>";
    }
    echo "</tr>\n";
}
开发者ID:ncbrown1,项目名称:OCS,代码行数:18,代码来源:content.php

示例8: explode

    } else {
        $action2 = $allowedAction2[$action][0];
    }
}
/**
		1. Traitement des données
	**/
if ($action == 'batch') {
    // Traitement des CSV importés
    if ($action2 == 'import' && count($_POST) > 0) {
        // Si fichier CSV envoyé
        if (isset($_POST['upload']) && isset($_FILES['csv']) && $_POST['upload'] == 'ok') {
            $fileName = explode('.', $_FILES['csv']['name']);
            if (is_file($_FILES['csv']['tmp_name']) && ($csv = fopen($_FILES['csv']['tmp_name'], 'r') && $fileName[count($fileName) - 1] == 'csv')) {
                // Récupération de la liste à partir du CSV
                $affectations = readCSV($_FILES['csv']['tmp_name'], ';', FALSE);
                /* On parcours le fichier $affectations et :
                 *	   - On enregistre dans l'array $affectationsOk['insert'] les valeurs  prêtes à être insérées
                 *    - On enregistre dans l'array $affectationsOk['erreur'] les valeurs qui posent probleme et qui ne doivent pas être insérées
                 */
                $affectationOk['insert'] = array();
                $affectationOk['erreur'] = array();
                foreach ($affectations as $affectationId => $affectationData) {
                    if (count($affectationData) >= 4) {
                        $erreurAffectation = checkAffectationInsertData(getUserIdFromNbEtudiant($affectationData[0]), $affectationData[1], $affectationData[2], $affectationData[3], array());
                        if (count($erreurAffectation) == 0) {
                            $affectationOk['insert'][$affectationId] = array('etudiant' => getUserIdFromNbEtudiant($affectationData[0]), 'service' => $affectationData[1], 'dateDebut' => $affectationData[2], 'dateFin' => $affectationData[3]);
                        } else {
                            $affectationOk['erreur'][$affectationId] = $erreurAffectation;
                        }
                    }
开发者ID:Galinijay,项目名称:PAS,代码行数:31,代码来源:affectations.php

示例9: get_data

 function get_data()
 {
     global $CFG, $COURSE, $USER;
     $data = parent::get_data();
     if (!$data) {
         return false;
     }
     if (isset($data->usecsvimport)) {
         // Set options from csv
         $usercontext = get_context_instance(CONTEXT_USER, $USER->id);
         $fs = get_file_storage();
         if (!($files = $fs->get_area_files($usercontext->id, 'user', 'draft', $data->csvfile, 'sortorder, id', false))) {
             return false;
         }
         if (count($files) != 1) {
             return false;
         }
         $csvfile = reset($files);
         $csv = readCSV($csvfile->get_content_file_handle(), true);
         // Manipulate $data to reflect form content (options, limit, grouping, optionid)
         $data = options_from_csv($data, $COURSE->id, $csv);
     }
     // Set up completion section even if checkbox is not ticked
     if (empty($data->completionsection)) {
         $data->completionsection = 0;
     }
     return $data;
 }
开发者ID:martinliao,项目名称:mod-groupreg,代码行数:28,代码来源:mod_form.php

示例10: uploadFile

    }
    if ($bStatus) {
        return $destino;
    } else {
        return $bStatus;
    }
    // De lo contrario un false
}
//function main()
if ($_POST["action"] == "upload") {
    $archivoDestino = uploadFile();
    //Subimos el archivo CVS
    if (!$archivoDestino) {
        die;
    }
    $archivoLimpio = readCSV($archivoDestino);
    //Pasamos el archivo CSV a un .txt que es una simple lista //Regresa un array de dos elementos, destino y la lista de los elementos
    $valoresY = implode(",", $archivoLimpio[1]);
    $valoresX = implode(",", $archivoLimpio[2]);
    //El de las fechas
    /*$max = max($archivoLimpio[1]); //Escalar en php es mala idea..!
    //$min = min($archivoLimpio[1]);
    $min = "0";
    $escalada = $archivoLimpio[1];
    $nueva = array();
    //echo implode(",", $escalada)."<br/>";
    //echo $max."..".$min."..";
    
    for($i = 0; $i < count($escalada); $i++)
    {
      //echo "".$escalada[$i]."...";
开发者ID:rafaellopezgtz,项目名称:neurored,代码行数:31,代码来源:index.php

示例11: tempnam

    } else {
        // successful
        echo $OUTPUT->notification(get_string('csv-import-success', 'groupreg'), 'notifysuccess');
    }
} else {
    if (!isset($_FILES['csvupload']) || $_FILES['csvupload']['size'] == 0) {
        // Output the confirmation form
        echo $renderer->display_import_assignment_form($cm, $action);
    } else {
        if ($_FILES['csvupload']['error'] > 0) {
            echo $OUTPUT->notification("Error: " . $_FILES["csvupload"]["error"]);
            echo $renderer->display_import_assignment_form($cm, $action);
        } else {
            // Move uploaded file, display contents to verify
            $filedest = tempnam("/tmp", "groupreg-importcsv");
            move_uploaded_file($_FILES["csvupload"]["tmp_name"], $filedest);
            // Verify contents, print result
            $csv = readCSV($filedest, false, ';');
            $errors = verifyCSV($csv, $action, $choice, $cm);
            if (isset($errors) && is_array($errors) && sizeof($errors) > 0) {
                //echo $OUTPUT->notification(implode("<br/>", $errors));
                show_errors($errors);
                echo $renderer->display_import_assignment_form($cm, $action);
            } else {
                // Verified, print table and continue
                echo display_csv_contents($cm, $filedest, $action, ';');
            }
        }
    }
}
echo $OUTPUT->footer();
开发者ID:martinliao,项目名称:mod-groupreg,代码行数:31,代码来源:import.php

示例12: readCSV

/* ================================================================
 *  
 *  @author : Régis Robineau
 *  @project : Equipex Biblissima
 *  @description : output a workable image sequence out of a basic 
 *  list of image urls. Retrieve w/h via info.json (IIIF Image API)
 *
 * ================================================================
*/
// Input file
$csvInputFile = "input/Lyon-0604-liens.csv";
// Output file
$csvOutputFile = "input/sequences_iiif/Lyon-0604-sequence.csv";
// Read csv input file
$csvInputData = readCSV($csvInputFile);
// Create empty array for the list of images (url, label)
$imgData = array();
// Loop through csv data
foreach ($csvInputData as $item) {
    // Set image label
    if ($item[8] !== ".JPG.tif") {
        $rv = strtolower($item[8]);
        $label = $item[7] . $rv;
    } else {
        $label = $item[7];
    }
    $img = array();
    $img["label"] = $label;
    //array_push($img, $label);
    // Set image url
开发者ID:regisrob,项目名称:gen_manifests_florus,代码行数:30,代码来源:buildICsvInput.php

示例13: readCSV

  </div>
  <!-- /#mapMenu -->
  <div class="mapBody">
  <div class="leftCol">
    <div class="af map"></div>
    <div class="as map"></div>
    <div class="cr map"></div>
    <div class="ca map"></div>
    <div class="eu map" style="display:block;"></div>
    <div class="na map"></div>
    <div class="oc map"></div>
    <div class="sa map"></div>
  </div>
  <div class="rightCol">
    <h3>Europe</h3>
    <div id="autoCompleteWrapper">
      <?php 
    $airports = readCSV();
    echo getCountries('eu', $airports);
    ?>
    </div>
    <div id="autoItemsWrapper"></div>
  </div>
</div>
</div>
<!-- / #airportsByMap -->

</body>
</html>
<?php 
}
开发者ID:bogiesoft,项目名称:hotelexpert,代码行数:31,代码来源:map.php

示例14: array

/**
		2. Traitement des donnés
	**/
if ($action == 'importCSVFile') {
    // Téléchargement du CSV vide
    if (isset($_GET['downloadCSV'])) {
        $arrayCSV[] = array(LANG_ADMIN_UTILISATEURS_MENU_BATCH_TABLE_NOM, LANG_ADMIN_UTILISATEURS_MENU_BATCH_TABLE_PRENOM, LANG_ADMIN_UTILISATEURS_MENU_BATCH_TABLE_MAIL, LANG_ADMIN_UTILISATEURS_MENU_BATCH_TABLE_NBETU, LANG_ADMIN_UTILISATEURS_MENU_BATCH_TABLE_PROMOTION, LANG_ADMIN_UTILISATEURS_MENU_BATCH_TABLE_RANG);
        downloadCSV($arrayCSV, 'import.csv');
    }
    // Traitement des CSV importés
    // Si fichier CSV envoyé
    if (isset($_POST['upload']) && isset($_FILES['csv']) && $_POST['upload'] == 'ok') {
        $fileName = explode('.', $_FILES['csv']['name']);
        if (is_file($_FILES['csv']['tmp_name']) && ($csv = fopen($_FILES['csv']['tmp_name'], 'r') && $fileName[count($fileName) - 1] == 'csv')) {
            // Récupération de la liste à partir du CSV
            $users = readCSV($_FILES['csv']['tmp_name'], ';', FALSE);
            // Corresponsance CSV -> Valeur
            $correspondance = array('nom' => 0, 'prenom' => 1, 'mail' => 2, 'nbEtu' => 3, 'promotion' => 4, 'rang' => 5);
            /* On parcours le fichier $users et :
             *	   - On enregistre dans l'array $userOK['insert'] les valeurs  prêtes à être insérées
             *	   - On enregistre dans l'array $userOK['update'] les valeurs  prêtes à être mises à jours
             *    - On enregistre dans l'array $userOK['erreur'] les valeurs qui posent probleme et qui ne doivent pas être insérées
             */
            $userOK['insert'] = array();
            $userOK['update'] = array();
            $userOK['erreur'] = array();
            foreach ($users as $usersId => $usersData) {
                $userData = array();
                foreach ($usersData as $key => $value) {
                    // On transforme la structure des mails
                    if (array_search($key, $correspondance) == 'mail') {
开发者ID:alibell,项目名称:PAS,代码行数:31,代码来源:ajouter.php

示例15: fopen

$accessToken = "4DK3_Q9x-YAAAAAAAAAAS-tnAaiFa42LXEBW2PIWTO4QpfVfMSVtf1kxAhf_WFU3";
$dbxClient = new dbx\Client($accessToken, "PHP-Example/1.0");
//list directory of dropbox
$folderMetadata = $dbxClient->getMetadataWithChildren("/");
// Set path to CSV file
$f = fopen($first_csv_file, "w+b");
$csv1_meta = $dbxClient->getFile("/" . $first_csv_file, $f);
fclose($f);
//Set path to CSV file
$f = fopen($second_csv_file, "w+b");
$csv2_meta = $dbxClient->getFile("/" . $second_csv_file, $f);
fclose($f);
$csv1 = readCSV($first_csv_file);
//Set path to CSV file
$csvFile = $second_csv_file;
$csv2 = readCSV($csvFile);
foreach ($csv1 as $s) {
    $array = array();
    $array[] = $s[0];
    $array[] = $s[2];
    $array[] = $s[4];
    $array[] = $s[5];
    $abc[] = $array;
}
$i = 0;
foreach ($csv2 as $s1) {
    $array = array();
    $abc[$i][] = $s1[0];
    $abc[$i][] = $s1[2];
    $abc[$i][] = $s1[3];
    $i++;
开发者ID:Vinay-c,项目名称:dropbox-api-test-job,代码行数:31,代码来源:index.php


注:本文中的readCSV函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。