• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP parseCSV类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了parseCSV类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: csvDataToMemcache

function csvDataToMemcache($csvList, $csvDir, $memIP, $memPort)
{
    $memcached = new Memcache();
    $memcached->connect($memIP, $memPort);
    foreach ($csvList as $key => $value) {
        $csvObj = new parseCSV();
        $csvObj->auto($csvDir . '/' . $value);
        list($fileName, $fileType) = explode('.', $value);
        $memcached->set($fileName, $csvObj->data, MEMCACHE_COMPRESSED, 0);
        //debug info
        //echo "<br/>--------------------------------------------$fileName.csv to memcache-------------------------------------------<br/>";
        print_r($memcached->get($fileName));
    }
    $memcached->close();
    echo "success";
}
开发者ID:YYLP,项目名称:y_game,代码行数:16,代码来源:load_csv_to_memcache.php


示例5: getCSV

 public static function getCSV($file_path, $limit = false, $offset = false)
 {
     if (file_exists($file_path) && is_readable($file_path)) {
         if (!class_exists('parseCSV')) {
             require_once GMEMBER_DIR . '/assets/libs/parsecsv-for-php/parsecsv.lib.php';
         }
         $csv = new parseCSV();
         $csv->encoding('UTF-16', 'UTF-8');
         if ($offset) {
             $csv->offset = $offset;
         }
         if ($limit) {
             $csv->limit = $limit;
         }
         $csv->auto($file_path);
         return array('titles' => $csv->titles, 'data' => $csv->data);
     }
     return false;
     return array('titles' => array(), 'data' => array());
 }
开发者ID:geminorum,项目名称:gmember,代码行数:20,代码来源:import.class.php


示例6: ImportCsv

 function ImportCsv($file_lines, $delims = array(";", ",", "\t"), $quotes = array('"', "'"))
 {
     function maxChar($chars, $testString)
     {
         $max_count = 0;
         $the_char = count($chars) > 0 ? $chars[0] : " ";
         foreach ($chars as $char) {
             $new_count = substr_count($testString, $char);
             if ($new_count > $max_count) {
                 $max_count = $new_count;
                 $the_char = $char;
             }
         }
         return $the_char;
     }
     $test_line = $file_lines[0];
     //
     // Detect the most probable delimiter.
     //
     $delim = maxChar($delims, $test_line);
     $quote = maxChar($quotes, $test_line);
     //
     // Re-Conncat the file-lines
     //
     $input = implode("\n", $file_lines) . "\n";
     //
     // Setup and run the parser
     //
     include "lib/parsecsv.lib.php";
     $csv = new parseCSV();
     $csv->delimiter = $delim;
     $csv->enclosure = $quote;
     $csv->file_data =& $input;
     $this->data = $csv->parse_string();
     //
     // Convert the array to addresses
     //
     $this->convertToAddresses();
 }
开发者ID:karanikn,项目名称:php-addressbook,代码行数:39,代码来源:import.csv.php


示例7: index

 function index()
 {
     if (!empty($this->data) && !empty($_POST['submit'])) {
         $string = explode(",", trim($this->data['InventoryMaster']['all_item']));
         $prsku = $string[0];
         if (!empty($string[1])) {
             $prname = $string[1];
         }
         if (!empty($prsku) && !empty($prname)) {
             $conditions = array('InventoryMaster.category LIKE' => '%' . $prname . '%', 'InventoryMaster.category LIKE' => '%' . $prsku . '%');
             $this->paginate = array('limit' => 1000, 'totallimit' => 2000, 'order' => 'InventoryMaster.id  ASC', 'conditions' => $conditions);
         }
         if (!empty($prsku)) {
             $conditions = array('OR' => array('InventoryMaster.product_code LIKE' => "%{$prsku}%", 'InventoryMaster.category LIKE' => "%{$prsku}%"));
             $this->paginate = array('limit' => 1000, 'totallimit' => 2000, 'order' => 'InventoryMaster.id  ASC', 'conditions' => $conditions);
         }
         $this->InventoryMaster->recursive = 1;
         $this->set('inventorymasters', $this->paginate());
     } else {
         if (!empty($_POST['checkid']) && !empty($_POST['exports'])) {
             // echo 'dfbgghbfg';die();
             $checkboxid = $_POST['checkid'];
             App::import("Vendor", "parsecsv");
             $csv = new parseCSV();
             $filepath = "C:\\Users\\Administrator\\Downloads" . "inventorymasterdb.csv";
             $csv->auto($filepath);
             $this->set('inventorymasters', $this->InventoryMaster->find('all', array('conditions' => array('InventoryMaster.id' => $checkboxid))));
             $this->layout = null;
             $this->autoLayout = false;
             Configure::write('debug', '2');
         } else {
             $this->InventoryMaster->recursive = 1;
             //$users = $this->InventoryMaster->User->find('list');
             $this->paginate = array('limit' => 1000, 'totallimit' => 2000, 'order' => 'InventoryMaster.id  ASC');
             $this->set('inventorymasters', $this->paginate());
         }
     }
 }
开发者ID:princespn,项目名称:listing-software,代码行数:38,代码来源:inventory_masters_controller_20janbk.php


示例8: parse_attendee_list

 public function parse_attendee_list($csv_text)
 {
     $csv = new parseCSV();
     $csv->delimiter = "\t";
     $csv->data = $csv->parse_string($csv_text);
     return $csv->data;
 }
开发者ID:CivicCommons,项目名称:oldBellCaPA,代码行数:7,代码来源:EventBrite.php


示例9: csvFileread

function csvFileread($target_file)
{
    # include parseCSV class.
    require_once 'parsecsv.lib.php';
    # create new parseCSV object.
    $csv = new parseCSV();
    # Parse '_books.csv' using automatic delimiter detection...
    $csv->auto("uploads/{$target_file}.csv");
    //$csv->auto("abc.csv");
    # ...or if you know the delimiter, set the delimiter character
    # if its not the default comma...
    $csv->delimiter = "\t";
    # tab delimited
    # ...and then use the parse() function.
    // $csv->parse('_books.csv');
    # Output result.
    echo "hello";
    print_r($csv->data);
    $i = 0;
    foreach ($csv->data as $key => $row) {
        print_r($row);
        if ($i == 5) {
            die;
        }
        $i++;
    }
}
开发者ID:Bushra230,项目名称:CSV,代码行数:27,代码来源:basicDemo.php


示例10: 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


示例11: index

 function index()
 {
     if (!empty($this->data) && !empty($_POST['submit'])) {
         $string = explode(",", trim($this->data['EbayenglishListing']['all_item']));
         $prsku = $string[0];
         if (!empty($string[1])) {
             $prname = $string[1];
         }
         if (!empty($prsku) && !empty($prname)) {
             $conditions = array('EbayenglishListing.title LIKE' => '%' . $prname . '%', 'EbayenglishListing.title LIKE' => '%' . $prsku . '%');
             $this->paginate = array('limit' => 1000, 'totallimit' => 2000, 'order' => 'EbayenglishListing.sku  id', 'conditions' => $conditions);
         }
         if (!empty($prsku)) {
             $conditions = array('OR' => array('EbayenglishListing.title LIKE' => "%{$prsku}%", 'EbayenglishListing.sku LIKE' => "%{$prsku}%"));
             $this->paginate = array('limit' => 1000, 'totallimit' => 2000, 'order' => 'EbayenglishListing.id  ASC', 'conditions' => $conditions);
         }
         $this->set('ebayenglishlistings', $this->paginate());
     } else {
         if (!empty($_POST['checkid']) && !empty($_POST['exports'])) {
             $checkboxid = $_POST['checkid'];
             App::import("Vendor", "parsecsv");
             $csv = new parseCSV();
             $filepath = "C:\\Users\\Administrator\\Downloads" . "ebayenglishlistings.csv";
             $csv->auto($filepath);
             $this->set('ebayenglishlistings', $this->EbayenglishListing->find('all', array('conditions' => array('EbayenglishListing.id' => $checkboxid))));
             $this->layout = null;
             $this->autoLayout = false;
             Configure::write('debug', '2');
         } else {
             $this->EbayenglishListing->recursive = 1;
             $this->paginate = array('limit' => 1000, 'totallimit' => 2000, 'order' => 'EbayenglishListing.id  ASC');
             $this->set('ebayenglishlistings', $this->paginate());
         }
     }
 }
开发者ID:princespn,项目名称:listing-software,代码行数:35,代码来源:ebayenglish_listings_controller111.php


示例12: upload

 public function upload()
 {
     ini_set("auto_detect_line_endings", true);
     ini_set('memory_limit', '512M');
     set_time_limit(600);
     require_once ROOT . DS . 'vendor' . DS . 'parsecsv.lib.php';
     try {
         $numberListTable = TableRegistry::get('NumberLists');
         $numberTable = TableRegistry::get('Numbers');
         // Generate temp file name
         $uploadFullPath = TMP . DS . Text::uuid();
         // Move file to temp location
         if (!move_uploaded_file($_FILES['file']['tmp_name'], $uploadFullPath)) {
             throw new \Exception('Cannot copy file to tmp location');
         }
         $dateTimeUtc = new \DateTimeZone('UTC');
         $now = new \DateTime('now', $dateTimeUtc);
         // Create new list
         $newNumberListData = ['list_name' => $this->request->data['list_name'], 'list_description' => $this->request->data['list_description'], 'create_datetime' => $now, 'update_datetime' => $now];
         $numberList = $numberListTable->newEntity($newNumberListData);
         $numberListTable->save($numberList);
         // Get the data from the file
         $csv = new \parseCSV();
         $csv->heading = false;
         $csv->auto($uploadFullPath);
         if (count($csv->data) == 0) {
             throw new \Exception('File is empty');
         }
         $newNumberData = [];
         foreach ($csv->data as $row) {
             $responseM360 = $this->M360->optInTfn($row[1]);
             //                $response['d'][] = $responseM360;
             $newNumberData = ['number_list_id' => $numberList->number_list_id, 'country_code' => $row[0], 'phone_number' => $row[1], 'opt_in_tfn' => (bool) $responseM360['Message360']['OptIns']['OptIn']['Status'] === 'updated', 'add_datetime' => $now];
             $number = $numberTable->newEntity($newNumberData);
             $numberTable->save($number);
         }
         //            $numbers = $numberTable->newEntity($newNumberData);
         //
         //            $numberTable->connection()->transactional(function () use ($numberTable, $numbers) {
         //                foreach ($numbers as $number) {
         //                    $numberTable->save($number, ['atomic' => false]);
         //                }
         //            });
         unlink($uploadFullPath);
         $response['i'] = $newNumberData;
         $response['status'] = 1;
     } catch (\Excaption $ex) {
         $response['status'] = 0;
         $response['message'] = $ex->getMessage();
     }
     $this->set(compact('response'));
     $this->set('_serialize', ['response']);
 }
开发者ID:Ytel-Inc,项目名称:ENS,代码行数:53,代码来源:NumberController.php


示例13: process

 /**
  * Renders the CSV.
  *
  * @return void
  */
 public function process()
 {
     $params = $this->gp;
     $exportParams = Tx_Formhandler_StaticFuncs::getSingle($this->settings, 'exportParams');
     if (!is_array($exportParams)) {
         $exportParams = t3lib_div::trimExplode(',', $exportParams);
     }
     //build data
     foreach ($params as $key => &$value) {
         if (is_array($value)) {
             $value = implode(',', $value);
         }
         if (count($exportParams) > 0 && !in_array($key, $exportParams)) {
             unset($params[$key]);
         }
         $value = str_replace('"', '""', $value);
     }
     // create new parseCSV object.
     $csv = new parseCSV();
     $csv->output('formhandler.csv', $data, $params);
     die;
 }
开发者ID:NaveedWebdeveloper,项目名称:Test,代码行数:27,代码来源:Tx_Formhandler_Generator_Csv.php


示例14: saveimport

 public function saveimport()
 {
     $response = array("status" => 0, "msg" => "Gagal simpan data");
     include APPPATH . "libraries/parsecsv.lib.php";
     // echo "<pre>";
     // print_r($_FILES);
     // echo "</pre>";
     if (isset($_FILES['inputFile']) && !empty($_FILES['inputFile']['name'])) {
         $files = $_FILES['inputFile'];
         $allowed_extension = array('csv');
         $extension = end(explode('.', strtolower($files['name'])));
         if (in_array($extension, $allowed_extension)) {
             $newname = date('YmdHis') . "_import_cpns.csv";
             if (move_uploaded_file($files['tmp_name'], _ROOT . "files/import/{$newname}")) {
                 if (file_exists(_ROOT . "files/import/{$newname}")) {
                     $response = array("status" => 0, "msg" => "sukses simpan data");
                     $destination = _ROOT . "files/import/{$newname}";
                     $csv = new parseCSV();
                     $data = $csv->auto($destination);
                     $datashipping = array();
                     foreach ((array) $csv->data as $index => $row) {
                         $save = $this->pengadaan_model->simpanDataCPNSimport($row);
                     }
                     $response = array("status" => 1, "msg" => "Sukses import file");
                 }
             }
         } else {
             $response = array("status" => 0, "msg" => "Ekstensi file harus .csv");
         }
     }
     // echo "<pre>";
     // print_r($response);
     // echo "</pre>";
     echo json_encode($response);
     exit;
 }
开发者ID:allfonso,项目名称:simpeg2,代码行数:36,代码来源:pengadaan.php


示例15: header

<?php

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


示例16: gigpress_import

function gigpress_import()
{
    // Deep breath
    global $wpdb, $gpo;
    // We've just uploaded a file to import
    check_admin_referer('gigpress-action');
    $upload = wp_upload_bits($_FILES['gp_import']['name'], null, file_get_contents($_FILES['gp_import']['tmp_name']));
    if (!$upload['error']) {
        // The file was uploaded, so let's try and parse the mofo
        require_once WP_PLUGIN_DIR . '/gigpress/lib/parsecsv.lib.php';
        // This is under MIT license, which ain't GNU, but was else is new? Don't tell on me!
        $csv = new parseCSV();
        $csv->parse($upload['file']);
        if ($csv->data) {
            // Looks like we parsed something
            $inserted = array();
            $skipped = array();
            $duplicates = array();
            foreach ($csv->data as $key => $show) {
                // Check to see if we have this artist
                $artist_exists = $wpdb->get_var("SELECT artist_id FROM " . GIGPRESS_ARTISTS . " WHERE artist_name = '" . mysql_real_escape_string($show['Artist']) . "'");
                if (!$artist_exists) {
                    // Can't find an artist with this name, so we'll have to create them
                    $new_artist = array('artist_name' => gigpress_db_in($show['Artist']));
                    $wpdb->insert(GIGPRESS_ARTISTS, $new_artist);
                    $show['artist_id'] = $wpdb->insert_id;
                } else {
                    $show['artist_id'] = $artist_exists;
                }
                if ($show['Tour']) {
                    // Check to see if we have this tour
                    $tour_exists = $wpdb->get_var("SELECT tour_id FROM " . GIGPRESS_TOURS . " WHERE tour_name = '" . mysql_real_escape_string($show['Tour']) . "' AND tour_status = 'active'");
                    if (!$tour_exists) {
                        // Can't find a tour with this name, so we'll have to create it
                        $order = $wpdb->get_var("SELECT count(*) FROM " . GIGPRESS_TOURS . " WHERE tour_status = 'active'");
                        $order++;
                        $new_tour = array('tour_name' => gigpress_db_in($show['Tour']));
                        $wpdb->insert(GIGPRESS_TOURS, $new_tour);
                        $show['tour_id'] = $wpdb->insert_id;
                    } else {
                        $show['tour_id'] = $tour_exists;
                    }
                }
                // Check to see if we have this venue
                $venue_exists = $wpdb->get_var("SELECT venue_id FROM " . GIGPRESS_VENUES . " WHERE venue_name = '" . mysql_real_escape_string($show['Venue']) . "' AND venue_city = '" . mysql_real_escape_string($show['City']) . "' AND venue_country = '" . mysql_real_escape_string($show['Country']) . "'");
                if (!$venue_exists) {
                    // Can't find a venue with this name, so we'll have to create it
                    $new_venue = array('venue_name' => gigpress_db_in($show['Venue']), 'venue_address' => gigpress_db_in($show['Address']), 'venue_city' => gigpress_db_in($show['City']), 'venue_country' => gigpress_db_in($show['Country']), 'venue_url' => gigpress_db_in($show['Venue URL']), 'venue_phone' => gigpress_db_in($show['Venue phone']));
                    $wpdb->insert(GIGPRESS_VENUES, $new_venue);
                    $show['venue_id'] = $wpdb->insert_id;
                } else {
                    $show['venue_id'] = $venue_exists;
                }
                if ($show['Time'] == FALSE) {
                    $show['Time'] = '00:00:01';
                }
                if ($wpdb->get_var("SELECT count(*) FROM " . GIGPRESS_SHOWS . " WHERE show_artist_id = " . $show['artist_id'] . " AND show_date = '" . $show['Date'] . "' AND show_time = '" . $show['Time'] . "' AND show_venue_id = " . $show['venue_id'] . " AND show_status != 'deleted'") > 0) {
                    // It's a duplicate, so log it and move on
                    $duplicates[] = $show;
                } else {
                    if ($show['End date'] == FALSE) {
                        $show['show_multi'] = 0;
                        $show['End date'] = $show['Date'];
                    } else {
                        $show['show_multi'] = 1;
                    }
                    $new_show = array('show_date' => $show['Date'], 'show_time' => $show['Time'], 'show_multi' => $show['show_multi'], 'show_expire' => $show['End date'], 'show_artist_id' => $show['artist_id'], 'show_venue_id' => $show['venue_id'], 'show_tour_id' => $show['tour_id'], 'show_ages' => gigpress_db_in($show['Admittance']), 'show_price' => gigpress_db_in($show['Price']), 'show_tix_url' => gigpress_db_in($show['Ticket URL']), 'show_tix_phone' => gigpress_db_in($show['Ticket phone']), 'show_notes' => gigpress_db_in($show['Notes'], FALSE), 'show_related' => '0');
                    // Are we importing related post IDs?
                    if (isset($_POST['include_related']) && ($_POST['include_related'] = 'y')) {
                        $new_show['show_related'] = $show['Related ID'];
                    }
                    $formats = array('%s', '%s', '%d', '%s', '%d', '%d', '%d', '%s', '%s', '%s', '%s', '%s', '%d');
                    $import = $wpdb->insert(GIGPRESS_SHOWS, $new_show, $formats);
                    if ($import != FALSE) {
                        $inserted[] = $show;
                    } else {
                        $skipped[] = $show;
                    }
                }
            }
            // end foreach import
            if (!empty($skipped)) {
                echo '<h4 class="error">' . count($skipped) . ' ' . __("shows were skipped due to errors", "gigpress") . '.</h4>';
                echo '<ul class="ul-square">';
                foreach ($skipped as $key => $show) {
                    echo '<li>' . wptexturize($show['Artist']) . ' ' . __("in", "gigpress") . ' ' . wptexturize($show['City']) . ' ' . __("at", "gigpress") . ' ' . wptexturize($show['Venue']) . ' ' . __("on", "gigpress") . ' ' . mysql2date($gpo['date_format'], $show['Date']) . '</li>';
                }
                echo '</ul>';
            }
            if (!empty($duplicates)) {
                echo '<h4 class="error">' . count($duplicates) . ' ' . __("shows were skipped as they were deemed duplicates", "gigpress") . '.</h4>';
                echo '<ul class="ul-square">';
                foreach ($duplicates as $key => $show) {
                    echo '<li>' . wptexturize($show['Artist']) . ' ' . __("in", "gigpress") . ' ' . wptexturize($show['City']) . ' ' . __("at", "gigpress") . ' ' . wptexturize($show['Venue']) . ' ' . __("on", "gigpress") . ' ' . mysql2date($gpo['date_format'], $show['Date']) . '</li>';
                }
                echo '</ul>';
            }
            if (!empty($inserted)) {
                echo '<h4 class="updated">' . count($inserted) . ' ' . __("shows were successfully imported", "gigpress") . '.</h4>';
                echo '<ul class="ul-square">';
//.........这里部分代码省略.........
开发者ID:Ashleyotero,项目名称:oldest-old,代码行数:101,代码来源:handlers.php


示例17: parseCSV

<pre>
<?php 
exit;
# 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 AND author is Dan Brown';
# Parse '_books.csv' using automatic delimiter detection.
$csv->auto('_books.csv');
# Output result.
// print_r($csv->data);
?>
</pre>
<style type="text/css" media="screen">
	table { background-color: #BBB; }
	th { background-color: #EEE; }
	td { background-color: #FFF; }
</style>
<table border="0" cellspacing="1" cellpadding="3">
	<tr>
		<?php 
foreach ($csv->titles as $value) {
    ?>
		<th><?php 
    echo $value;
    ?>
开发者ID:edmarmoretti,项目名称:i3geo,代码行数:31,代码来源:conditions.php


示例18: import_gradebook_screen

 /**
  * import_gradebook_screen( $vars )
  *
  * Hooks into screen_handler
  * Imports a CSV file data into the gradebook_screen(). It doesn't save anything!
  *
  * @param Array $vars a set of variables received for this screen template
  * @return Array $vars a set of variable passed to this screen template
  */
 function import_gradebook_screen($vars)
 {
     $is_nonce = nxt_verify_nonce($_POST['_nxtnonce'], 'gradebook_import_nonce');
     if (!$is_nonce) {
         $vars['die'] = __('BuddyPress Courseware Nonce Error while importing gradebook.', 'bpsp');
         return $this->gradebook_screen($vars);
     }
     $grades = array();
     if (isset($_FILES['csv_filename']) && !empty($_FILES['csv_filename'])) {
         require_once 'parseCSV.class.php';
         // Load CSV parser
         $csv = new parseCSV();
         $csv->auto($_FILES['csv_filename']['tmp_name']);
         foreach ($csv->data as $grade) {
             $id = bp_core_get_userid_from_nicename($grade['uid']);
             if ($id) {
                 $grades[$id] = $grade;
             }
         }
         if (count($csv->data) == count($grades)) {
             $vars['message'] = __('Data imported successfully, but it is not saved yet! Save this form changes to keep the data.', 'bpsp');
         } else {
             $vars['error'] = __('File data contains error or entries from other gradebook. Please check again.', 'bpsp');
         }
     }
     $vars['grades'] = $grades;
     $vars['assignment_permalink'] = $vars['assignment_permalink'] . '/gradebook';
     unset($_POST);
     return $this->gradebook_screen($vars);
 }
开发者ID:nxtclass,项目名称:NXTClass-Plugin,代码行数:39,代码来源:gradebook.class.php


示例19: download_export_log

 /**
  * Create CSV File Export
  * @since 1.4
  * @version 1.0.1
  */
 public function download_export_log()
 {
     if (!isset($_REQUEST['mycred-export']) || $_REQUEST['mycred-export'] != 'do') {
         return;
     }
     // Must be logged in
     if (!is_user_logged_in()) {
         return;
     }
     // Make sure current user can export
     if (!apply_filters('mycred_user_can_export', false) && !$this->core->can_edit_creds()) {
         return;
     }
     // Security for front export
     if (apply_filters('mycred_allow_front_export', false) === true) {
         if (!isset($_REQUEST['token']) || !wp_verify_nonce($_REQUEST['token'], 'mycred-run-log-export')) {
             return;
         }
     } else {
         check_admin_referer('mycred-run-log-export', 'token');
     }
     $type = '';
     $data = array();
     // Sanitize the log query
     foreach ((array) $_POST as $key => $value) {
         if ($key == 'action') {
             continue;
         }
         $_value = sanitize_text_field($value);
         if ($_value != '') {
             $data[$key] = $_value;
         }
     }
     // Get exports
     $exports = mycred_get_log_exports();
     if (empty($exports)) {
         return;
     }
     // Identify the export type by the action button
     foreach ($exports as $id => $info) {
         if ($info['label'] == $_POST['action']) {
             $type = $id;
             break;
         }
     }
     // Act according to type
     switch ($type) {
         case 'all':
             $old_data = $data;
             unset($data);
             $data = array();
             $data['ctype'] = $old_data['ctype'];
             $data['number'] = -1;
             break;
         case 'search':
             $data['number'] = -1;
             break;
         case 'displayed':
         default:
             $data = apply_filters('mycred_export_log_args', $data);
             break;
     }
     // Custom Exports
     if (has_action('mycred_export_' . $type)) {
         do_action('mycred_export_' . $type, $data);
     } else {
         // Query the log
         $log = new myCRED_Query_Log($data, true);
         // If there are entries
         if ($log->have_entries()) {
             $export = array();
             // Loop though results
             foreach ($log->results as $entry) {
                 // Remove the row id
                 unset($entry['id']);
                 // Make sure entry and data does not contain any commas that could brake this
                 $entry['entry'] = str_replace(',', '', $entry['entry']);
                 $entry['data'] = str_replace(',', '.', $entry['data']);
                 // Add to export array
                 $export[] = $entry;
             }
             $log->reset_query();
             // Load parseCSV
             require_once myCRED_ASSETS_DIR . 'libs/parsecsv.lib.php';
             $csv = new parseCSV();
             // Run output and lets create a CSV file
             $date = date_i18n('Y-m-d');
             $csv->output(true, 'mycred-log-' . $date . '.csv', $export, array('ref', 'ref_id', 'user_id', 'creds', 'ctype', 'time', 'entry', 'data'));
             die;
         }
         $log->reset_query();
     }
 }
开发者ID:kfwebdev,项目名称:wp-atd,代码行数:98,代码来源:mycred-module-log.php


示例20: mapFileInvoice

 private function mapFileInvoice()
 {
     $file = Input::file('file');
     if ($file == null) {
         Session::flash('error', trans('texts.select_file'));
         return Redirect::to('company/import_export');
     }
     $name = $file->getRealPath();
     require_once app_path() . '/includes/parsecsv.lib.php';
     $csv = new parseCSV();
     $csv->heading = false;
     $csv->auto($name);
     Session::put('data', $csv->data);
     $headers = false;
     $hasHeaders = false;
     $mapped = array();
     $columns = array('', Invoice::$fieldCodClient, Invoice::$fieldProduct, Invoice::$fieldAmount);
     if (count($csv->data) > 0) {
         $headers = $csv->data[0];
         foreach ($headers as $title) {
             if (strpos(strtolower($title), 'name') > 0) {
                 $hasHeaders = true;
                 break;
             }
         }
         for ($i = 0; $i < count($headers); $i++) {
             $title = strtolower($headers[$i]);
             $mapped[$i] = '';
             if ($hasHeaders) {
                 $map = array('cod_client' => Invoice::$fieldCodClient, 'product' => Invoice::$fieldProduct, 'amount' => Invoice::$fieldAmount);
                 foreach ($map as $search => $column) {
                     foreach (explode("|", $search) as $string) {
                         if (strpos($title, 'sec') === 0) {
                             continue;
                         }
                         if (strpos($title, $string) !== false) {
                             $mapped[$i] = $column;
                             break 2;
                         }
                     }
                 }
             }
         }
     }
     $data = array('data' => $csv->data, 'headers' => $headers, 'hasHeaders' => $hasHeaders, 'columns' => $columns, 'mapped' => $mapped);
     $data['branches'] = Branch::where('account_id', '=', Auth::user()->account_id)->orderBy('id')->get();
     return View::make('accounts.import_map_invoice', $data);
 }
开发者ID:aleguisf,项目名称:fvdev1,代码行数:48,代码来源:AccountController.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP parse_message类代码示例发布时间:2022-05-23
下一篇:
PHP parent类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap