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


PHP parseCSV::parse方法代码示例

本文整理汇总了PHP中parseCSV::parse方法的典型用法代码示例。如果您正苦于以下问题:PHP parseCSV::parse方法的具体用法?PHP parseCSV::parse怎么用?PHP parseCSV::parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在parseCSV的用法示例。


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

示例1: parse_file

 protected function parse_file($file)
 {
     $csv = new \parseCSV();
     $csv->delimiter = ";";
     $csv->parse($file);
     if ($this->tag_ok) {
         $tableHead = "<div  class='table-respond'><table><thead><tr><th>Titre</th><th>Album</th></tr></thead><tbody>";
     } else {
         $tableHead = "<div  class='table-respond'><table><thead><tr><th>Titre</th><th>Artiste</th><th>Album</th></tr></thead><tbody>";
     }
     $tableEnd = "</tbody></table></div>";
     $tableBody = "";
     foreach ($csv->data as $key => $row) {
         $annee = "";
         $groupe = "";
         if ($this->tag_ok) {
             if (isset($row['Groupe']) && strpos(html_entity_decode($row['Groupe']), html_entity_decode($this->tag_name)) !== false) {
                 if ($row['Année']) {
                     $annee = "<span class='playlist_year'> (" . $row['Année'] . ")</span>";
                 }
                 $tableBody .= "<tr><td>" . $row['Titre'] . "</td><td>" . $row['Album'] . $annee . "</td></tr>";
             }
         } else {
             if ($row['URL']) {
                 if ($row['Groupe']) {
                     $groupe = "<a href='" . $row['URL'] . "' title='" . $row['URL'] . "' target='_blank'>" . $row['Groupe'] . "</a>";
                 } else {
                     $row['Titre'] = "<a href='" . $row['URL'] . "' title='" . $row['URL'] . "' target='_blank'>" . $row['Titre'] . "</a>";
                 }
             } else {
                 $groupe = $row['Groupe'];
             }
             if ($row['Année']) {
                 $annee = "<span class='playlist_year'> (" . $row['Année'] . ")</span>";
             }
             $tableBody .= "<tr><td>" . $row['Titre'] . "</td><td>" . $groupe . "</td><td>" . $row['Album'] . $annee . "</td></tr>";
         }
     }
     $ret = $tableHead . $tableBody . $tableEnd;
     return $ret;
 }
开发者ID:bricebou,项目名称:ecparsecsv,代码行数:41,代码来源:Plugin.php

示例2: read

 public function read()
 {
     global $default_charset;
     $filePath = $this->getFilePath();
     $status = $this->createTable();
     if (!$status) {
         return false;
     }
     $csv = new parseCSV();
     $csv->delimiter = $this->request->get('delimiter');
     $csv->parse($filePath);
     $data = $csv->data;
     $fieldMapping = $this->request->get('field_mapping');
     if (!$this->request->get('has_header')) {
         $firstRow = array_keys($data[0]);
         array_unshift($data, $firstRow);
     }
     foreach ($data as $row_data) {
         $row_data_index = array_values($row_data);
         $mappedData = array();
         $allValuesEmpty = true;
         foreach ($fieldMapping as $fieldName => $index) {
             $fieldValue = $row_data_index[$index];
             $mappedData[$fieldName] = $fieldValue;
             if ($this->request->get('file_encoding') != $default_charset) {
                 $mappedData[$fieldName] = $this->convertCharacterEncoding($fieldValue, $this->request->get('file_encoding'), $default_charset);
             }
             if (!empty($fieldValue)) {
                 $allValuesEmpty = false;
             }
         }
         if ($allValuesEmpty) {
             continue;
         }
         $fieldNames = array_keys($mappedData);
         $fieldValues = array_values($mappedData);
         $this->addRecordToDB($fieldNames, $fieldValues);
     }
 }
开发者ID:gitter-badger,项目名称:openshift-salesplatform,代码行数:39,代码来源:SPCSVReader.php

示例3: processData

 /**
  * @param $inputData
  * @return MerchantDataListing[]
  */
 public function processData($inputData)
 {
     $inputData = mb_convert_encoding($inputData, "utf-8", "windows-1252");
     $csv = new \parseCSV();
     //$csv->encoding('Windows-1252', 'UTF-8');
     $csv->delimiter = "\t";
     $csv->parse($inputData);
     $itemList = array();
     foreach ($csv->data as $row) {
         $item = new MerchantDataListing();
         $item->setData($row);
         $itemList[] = $item;
     }
     return $itemList;
 }
开发者ID:sebastien-fauvel,项目名称:Amazon-Mws-Repricing,代码行数:19,代码来源:MerchantDataListingProcessor.php

示例4: parseFind

function parseFind($csvFile, $afm, $surname)
{
    // init vars
    $empOffset = 5;
    $anadrData = [];
    // parse csv & find employee
    $csv = new parseCSV();
    $csv->encoding('iso8859-7', 'UTF-8');
    $csv->delimiter = ";";
    $csv->heading = false;
    // find employee T.M.
    $csv->offset = $empOffset;
    $condition = '8 is ' . $afm . ' AND 1 contains ' . grstrtoupper($surname);
    $csv->conditions = $condition;
    $csv->parse($csvFile);
    $parsed = $csv->data;
    // enhanced check of surname (instead of 'contains' in fullname)
    if ($parsed) {
        $tmp = explode(' ', $parsed[0][1]);
        $fileSurname = $tmp[0];
        if (strcmp(grstrtoupper($surname), $fileSurname) != 0) {
            return ['parsed' => [], 'month' => []];
        }
    }
    // find month
    $csv->offset = 1;
    $csv->conditions = '19 contains ΜΙΣΘΟΔΟΣΙΑ';
    $csv->parse($csvFile);
    //$csv->fields =[19];
    $data = $csv->data;
    $tmp = explode(' ', $data[0][19]);
    $month = $tmp[2] . '_' . $tmp[3];
    // find anadromika (if any)
    $csv->offset = $empOffset;
    $csv->conditions = '';
    $csv->parse($csvFile);
    $data = $csv->data;
    $i = $foundFrom = $foundTo = 0;
    foreach ($data as $row) {
        if (array_key_exists('8', $row) && $afm == $row[8] && !$foundFrom) {
            $foundFrom = $i;
        }
        if ($foundFrom && !$foundTo && array_key_exists('8', $row)) {
            if ($row[8] != '' && $row[8] != $afm) {
                $foundTo = $i - 1;
            }
        }
        $i++;
    }
    $tempData = array_slice($data, $foundFrom, $foundTo - $foundFrom + 1);
    foreach ($tempData as $line) {
        if ($line[10] == 'ΑΝΑΔΡΟΜΙΚΑ') {
            $anadrData = $line;
        }
    }
    if (count($anadrData) > 0) {
        array_push($parsed, $anadrData);
    }
    return ['parsed' => $parsed, 'month' => $month];
}
开发者ID:dipeira,项目名称:espa-payments,代码行数:60,代码来源:functions.php

示例5: parseCSV

<?php

require_once 'check.php';
$csv = new parseCSV();
$csv->parse('../00_ADMIN_CSV_FOLDER/bodytype_service_pricing_minutes.csv');
$bodytype_service = array($csv->data);
$csv->parse('../00_ADMIN_CSV_FOLDER/extra_pricing_minutes.csv');
$extra_pricing = array($csv->data);
$csv->parse('../00_ADMIN_CSV_FOLDER/service_discounts.csv');
$service_discounts = array($csv->data);
开发者ID:CallumJHays,项目名称:WonderfulServices,代码行数:10,代码来源:csv-to-array.php

示例6: explode

$time = explode(' ', $time);
$time = $time[1] + $time[0];
$start = $time;
//require ("../../php/sessionStartAndCheck.php");
# include parseCSV class.
require_once '../parsecsv.lib.php';
# create new parseCSV object.
$csv = new parseCSV();
# Example conditions:
// $csv->conditions = 'title contains paperback OR title contains hardcover';
// $csv->conditions = 'author does not contain dan brown';
// $csv->conditions = 'rating < 4 OR author is John Twelve Hawks';
// $csv->conditions = 'rating > 4';
// $csv->conditions = 'Data is empty';
// $csv->conditions = 'Data is not empty';
$csv->parse('../out/test.csv', 0, 1000);
// At max 1000 lines.
if ($csv->error_info) {
    print_r($csv->error_info);
}
?>
<!doctype html>
<html>
<head>
  <meta charset='utf-8'>
  <title>Conditional formatting - Handsontable</title>

  <!--
  Loading Handsontable dependencies.
  Please note that some dependencies are optional:
   - bootstrap-typeahead.js - is required only if you need the autocomplete feature
开发者ID:jonca44,项目名称:pdf-mailmerge,代码行数:31,代码来源:index.php

示例7: importCSV

 public static function importCSV()
 {
     $csv_mimetypes = array('text/csv', 'text/plain', 'application/csv', 'text/comma-separated-values', 'application/excel', 'application/vnd.ms-excel', 'application/vnd.msexcel', 'text/anytext', 'application/octet-stream', 'application/txt', 'application/vnd.google-apps.spreadsheet');
     foreach ($_FILES as $file) {
         if (in_array($file['type'], $csv_mimetypes)) {
             require_once plugin_dir_path(__FILE__) . "/parseCSV.php";
             $csv = new parseCSV();
             if ($_POST["first_row"] == "false") {
                 $csv->heading = false;
             }
             $csv->parse($file['tmp_name']);
             echo json_encode($csv->data);
         } else {
             echo json_encode(array("error" => "File Must be a CSV"));
         }
         die;
     }
 }
开发者ID:andrewkhunn,项目名称:lancero,代码行数:18,代码来源:class-weblator-charts-ajax.php

示例8: mkdir

} else {
    $subdir .= "/generated_documents/";
}
if (!is_dir($upload_dir . $subdir)) {
    mkdir($upload_dir . $subdir, 0700, true);
}
$filename = create_filename() . ".pdf";
$pdf = new FPDF2File();
$pdf->Open($upload_dir . $subdir . $filename);
$pdf->SetAutoPageBreak(false, 0);
$pdf->SetMargins(0, 0, 0);
//$pdf->AliasNbPages();
$csvHeaders = array();
if ($server->outData['data'][1]['datasource_file_name'] !== "") {
    if (isset($server->outData['data'][1]['datasource_file_name'])) {
        $csv->parse(".." . $server->outData['data'][1]['datasource_data_path'] . $server->outData['data'][1]['datasource_file_name'], 0, 1000);
        // At max 1000 lines.
        //Leon 24-03-14 - Add this back in, and add error handling into the page designer to print a handy error message to the user
        //if($csv->error_info) {
        //	die(array("error" => 1, "details" => print_r($csv->error_info, 1)) );
        //}
        foreach ($csv->titles as $key => $header) {
            $csvHeaders[] = "<" . $header . ">";
        }
        if (count($csv->data) == 0) {
            $csv->data[] = array();
        }
    } else {
        $csv->data[] = array();
    }
}
开发者ID:jonca44,项目名称:pdf-mailmerge,代码行数:31,代码来源:createPDF.php

示例9: import

 /**
  * @todo Implement truncate
  *
  */
 function import()
 {
     set_time_limit(0);
     $file = $this->controller->data[$this->modelName]['csv']['tmp_name'];
     $truncate = $this->controller->data[$this->modelName]['truncate'];
     $model = $this->controller->{$this->modelName};
     // truncate the table.
     if ($truncate) {
         #$model->contain();
         $model->deleteAll(array(1 => 1));
     }
     // parseCSV does lots of magic to fill $csv->data
     App::import('Vendor', 'advindex.parseCSV', array('file' => 'parsecsv-0.3.2' . DS . 'parsecsv.lib.php'));
     $csv = new parseCSV();
     $csv->parse($file);
     // Process data.
     $fields = array_flip($this->settings['fields']);
     $errors = array();
     $created = $updated = 0;
     // Callbacks.
     $hasBeforeCallback = method_exists($model, 'beforeImport');
     $hasAfterCallback = method_exists($model, 'afterImport');
     foreach ($csv->data as $line => $row) {
         // start again
         $model->create();
         // get row
         $row2 = array();
         foreach ($row as $field => $val) {
             $alias = $model->alias;
             if (strpos($field, '.') !== false) {
                 list($alias, $field) = explode('.', $field);
             }
             $row2[$alias][$field] = $val;
         }
         $row = $row2;
         unset($row2);
         // format row
         if ($hasBeforeCallback) {
             $modelData = $model->beforeImport($row);
         } else {
             $modelData = $this->genericBeforeImport($row);
         }
         // try and find an existing row.
         $update = false;
         $conditions = array();
         $contain = array();
         foreach ($this->settings['update_if_fields'] as $field) {
             if (!empty($modelData[$field])) {
                 $conditions[$field] = $modelData[$field];
             }
         }
         if ($conditions && ($record = $model->find('first', compact('conditions', 'contain')))) {
             $modelData[$model->primaryKey] = $record[$this->modelName][$model->primaryKey];
             $update = true;
         }
         if ($saved = $model->saveAll($modelData)) {
             $update ? $updated++ : $created++;
             if ($hasAfterCallback) {
                 $model->afterImport($modelData);
             }
         } else {
             $errors[$line] = $model->validationErrors;
         }
     }
     $this->controller->Session->write('Advindex.' . $this->modelName . '.import', compact('created', 'updated', 'errors'));
     $this->controller->redirect(array('action' => 'index'));
 }
开发者ID:morrislaptop,项目名称:advindex,代码行数:71,代码来源:AdvindexComponent.php

示例10: createDBDataSource

 private function createDBDataSource($filename, $options, $subdir, $file_path)
 {
     global $session, $sql;
     $query = "INSERT INTO datasources (created_at, updated_at, user_id, name, data_path, file_name, `headers`, `lines`)\n\t\t\t\t  VALUES(?, NOW(), ?, ?, ?, ?, ?, ?)";
     $stmt = $sql->link->prepare($query);
     if (!$stmt) {
         die('Invalid query: ' . $sql->link->error);
     } else {
         $csv = new parseCSV();
         $realUserPath = realpath($file_path);
         if (filesize($realUserPath) > 0) {
             $csv->parse($realUserPath, 0, 10000);
             // At max 10000 lines.
             $csvDataRows = $csv->unparse($csv->data, $csv->titles, null, null, null, true);
         } else {
             $csvDataRows = array(array(""));
         }
         $lines = count($csvDataRows) - 1;
         $headers = json_encode($csv->titles);
         $subdirSQL = $options['upload_url'] . $subdir;
         $time = getCurrentDateTime();
         $userID = $this->session->get_user_var('id');
         $stmt->bind_param('sissssi', $time, $userID, $filename, $subdirSQL, $filename, $headers, $lines);
         $resultFromExec = $stmt->execute();
         if ($resultFromExec) {
             $affectedRows = $stmt->affected_rows;
         }
         /* free result */
         $stmt->free_result();
         $stmt->close();
     }
     return array("lines" => $lines, "headers" => implode(", ", array_filter($csv->titles)));
 }
开发者ID:jonca44,项目名称:pdf-mailmerge,代码行数:33,代码来源:upload.class.php

示例11: json_encode

<?php

header('Content-Type: application/json');
require_once '../parsecsv-for-php/parsecsv.lib.php';
$csv = new parseCSV();
$csv->parse('../../../00_ADMIN_CSV_FOLDER/extra_pricing_minutes.csv');
echo json_encode($csv->data);
开发者ID:CallumJHays,项目名称:WonderfulServices,代码行数:7,代码来源:extra_pricing.php

示例12: ManageFile

    <?php 
$algumacoisa = new ManageFile();
$algumacoisa->setDir('arquivos/' . $course . '/' . $turma);
$alunos = $algumacoisa->readDir('nome', 'asc');
foreach ($alunos as $aluno) {
    if ($aluno['nome'] == '.' || $aluno['nome'] == '..') {
        $key = array_search($aluno, $alunos);
        unset($alunos[$key]);
    }
}
if ($alunos == null) {
    echo '<h4>Não há ninguém cadastrado nessa turma</h4>';
}
$outra = new parseCSV();
$outra->delimiter = ';';
$outra->parse('dados.csv');
$dados_alunos = $outra->data;
foreach ($dados_alunos as $chave => $dado) {
    $nome[$chave] = $dado['nome'];
}
array_multisort($nome, SORT_ASC, $dados_alunos);
foreach ($dados_alunos as $dados) {
    foreach ($alunos as $aluno) {
        $aluno_nome = explode('.', $aluno['nome']);
        if ($dados['matricula'] == $aluno_nome[0]) {
            $dados_deste_aluno = $dados;
        }
    }
    ?>
        <div class="col-sm-4">
            <div class="panel panel-primary">
开发者ID:germanocorrea,项目名称:carometro,代码行数:31,代码来源:turma-page.php

示例13: AddLangsFromTxt

 /**
     Loads lang list from Languages.txt file and fill its parameters
     Note: can not fill po files
 */
 protected function AddLangsFromTxt()
 {
     $languagelistFileName = $this->infoDir . 'Languages/Languages.txt';
     // r1434 - today
     if (!file_exists($languagelistFileName)) {
         debug("File {$languagelistFileName} does not exixts!<br/>");
         $languagelistFileName = $this->infoDir . 'src/Languages/Languages.txt';
         // r1302 - r1433
     }
     if (!file_exists($languagelistFileName)) {
         debug("File {$languagelistFileName} does not exixts!<br/>");
         debug("No file to process found !<br/>");
         return false;
     }
     debug("Processing file {$languagelistFileName}.<br/>");
     // load language.txt
     $csv = new parseCSV();
     $csv->delimiter = ";";
     $csv->parse($languagelistFileName);
     foreach ($csv->data as $csvLine) {
         if (!isset($csvLine) || !is_array($csvLine) || count($csvLine) < 1) {
             continue;
         }
         $indexedArray = array_values($csvLine);
         if ($indexedArray[0][0] == '#') {
             // to do process if everithing else match - aka commented out lang
             continue;
         }
         $ret = array();
         switch (count($csvLine)) {
             case 6:
                 /*echo "<br /><pre>";
                   var_dump($indexedArray);
                   echo "</pre>";
                   /*if (preg_match("/^[-01]/", $indexedArray[0])) {
                       $ret['Enabled']=$indexedArray[0];
                       $ret['Code']=$indexedArray[1];
                       //$ret['Lang']=$indexedArray[2];
                       $ret['Flags']=$indexedArray[3];
                       $ret['LangName']=$indexedArray[4];
                       $ret['Credits']=$indexedArray[5];
                   } else {
                       $ret['Code']=$indexedArray[0];
                       //$ret['Lang']=$indexedArray[1];
                       $ret['Enabled']=$indexedArray[2];
                       //$ret['Flags']=$indexedArray[3];
                       $ret['LangName']=$indexedArray[4];
                       //$ret['Credits']=$indexedArray[5];
                       // Credits should be loaded from other file ... (vars)
                   }//*/
                 // 21716 -
                 $ret['Code'] = trim($indexedArray[0]);
                 $ret['WixLang'] = trim($indexedArray[1]);
                 //$ret['LCID']=trim($indexedArray[2]);
                 $ret['SC'] = trim($indexedArray[3]);
                 $ret['LangName'] = trim($indexedArray[4]);
                 $ret['Credits'] = trim($indexedArray[5]);
                 break;
             case 7:
                 $ret['Enabled'] = trim($indexedArray[0]);
                 $ret['Code'] = trim($indexedArray[1]);
                 $ret['WixLang'] = trim($indexedArray[2]);
                 $ret['Lang'] = trim($indexedArray[3]);
                 $ret['Flags'] = trim($indexedArray[4]);
                 $ret['LangName'] = trim($indexedArray[5]);
                 $ret['Credits'] = trim($indexedArray[6]);
         }
         if (count($ret) > 0) {
             $this->UpdateLang($ret);
         }
     }
 }
开发者ID:Kasper8660,项目名称:tortoisesvn,代码行数:76,代码来源:source.php

示例14: parse

 public function parse()
 {
     include_once JPATH_SITE . '/components/com_acctexp/lib/parsecsv/parsecsv.lib.php';
     $csv = new parseCSV();
     $csv->heading = false;
     $this->rows = $csv->parse($this->filepath);
     if ($csv->parse($this->filepath)) {
         $this->rows = $csv->data;
         return true;
     } else {
         return false;
     }
 }
开发者ID:Ibrahim1,项目名称:aec,代码行数:13,代码来源:admin.acctexp.class.php

示例15: strtoupper

 if (!isset($tema)) {
     $nomex = strtoupper($i3GEOuploaddbfnomex);
     $nomey = strtoupper($i3GEOuploaddbfnomey);
     //converte de csv para dbf
     if ($i3GEOuploaddbftipoarquivo != "dbf") {
         if ($i3GEOuploaddbftipoarquivo == "csvpv") {
             $separador = ";";
         }
         if ($i3GEOuploaddbftipoarquivo == "csvv") {
             $separador = ",";
         }
         include_once dirname(__FILE__) . "/../../pacotes/phpxbase/api_conversion.php";
         include_once dirname(__FILE__) . "/../../pacotes/parsecsv/parsecsv.lib.php";
         $csv = new parseCSV();
         $csv->delimiter = $separador;
         $dados = $csv->parse($dirmap . "/" . $ArquivoDest);
         $conta = 0;
         $xy = array();
         $colunas = array_keys($csv->data[0]);
         foreach ($colunas as $i) {
             $i = strtoupper($i);
             $i = trim($i);
             if ($i != $nomex && $i != $nomey) {
                 $i = str_replace("_", "", $i);
                 $i = str_replace("-", "", $i);
                 if (strlen($i) > 10) {
                     $i = substr($i, 0, 7) . $conta++;
                 }
                 $def[] = array($i, "C", "255");
             } else {
                 $def[] = array($i, "C", "255");
开发者ID:edmarmoretti,项目名称:i3geo,代码行数:31,代码来源:upload.php


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