當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Writer::writeRow方法代碼示例

本文整理匯總了PHP中Writer::writeRow方法的典型用法代碼示例。如果您正苦於以下問題:PHP Writer::writeRow方法的具體用法?PHP Writer::writeRow怎麽用?PHP Writer::writeRow使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Writer的用法示例。


在下文中一共展示了Writer::writeRow方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: dirname

<?php

namespace EasyCSV;

require_once dirname(dirname(__DIR__)) . '/inc/common.php';
foreach (glob(CKANMNGR_DATA_DIR . '/organizations.json') as $json_file) {
    $json = json_decode(file_get_contents($json_file), true);
    //  decode as assoc array
    $basename = str_replace('.json', '', basename($json_file));
    $writer = new Writer(CKANMNGR_DATA_DIR . '/' . $basename . '.csv');
    //    $writer->writeRow([
    //        'from',
    //        'to'
    //    ]);
    foreach ($json['result'] as $organization) {
        $writer->writeRow([$organization['name']]);
    }
}
// show running time on finish
timer();
開發者ID:bg6aer,項目名稱:ckan-php-manager,代碼行數:20,代碼來源:organizations_json_to_csv.php

示例2: dirname

<?php

namespace EasyCSV;

require_once dirname(dirname(__DIR__)) . '/inc/common.php';
foreach (glob(CKANMNGR_DATA_DIR . '/de*.json') as $json_file) {
    $dataset_names = json_decode(file_get_contents($json_file), true);
    //  decode as assoc array
    $basename = str_replace('.json', '', basename($json_file));
    $writer = new Writer(CKANMNGR_DATA_DIR . '/' . $basename . '.csv');
    $writer->writeRow(['from', 'to']);
    foreach ($dataset_names['name'] as $name => $count) {
        $newName = preg_replace("/^deleted-/", '', $name);
        $writer->writeRow([$name, $newName]);
    }
}
// show running time on finish
timer();
開發者ID:bg6aer,項目名稱:ckan-php-manager,代碼行數:18,代碼來源:convert_json_to_csv.php

示例3: Reader

    //    fix wrong END-OF-LINE
    file_put_contents($csv_file, preg_replace('/[\\r\\n]+/', "\n", file_get_contents($csv_file)));
    $csv_source = new Reader($csv_file, 'r+', false);
    $csv_destination = new Writer($results_dir . '/' . $basename . '_long.csv');
    $i = 0;
    while (true) {
        if (!($i++ % 50)) {
            echo $i . PHP_EOL;
        }
        $row = $csv_source->getRow();
        if (!$row) {
            break;
        }
        //        skip headers
        if (in_array(trim(strtolower($row[0])), ['socrata code', 'from'])) {
            $csv_destination->writeRow($row);
            continue;
        }
        $socrata_id = $row[0];
        $ckan_url = $row[1];
        //        writing short redirect
        $socrata_short_url = 'https://explore.data.gov/d/' . $socrata_id;
        $csv_destination->writeRow([$socrata_short_url, $ckan_url]);
        $socrata_long_url = get_long_socrata_url($curl_ch, $socrata_short_url);
        if (!$socrata_long_url) {
            echo 'No result: ' . $socrata_short_url . PHP_EOL;
        }
        $csv_destination->writeRow([$socrata_long_url, $ckan_url]);
    }
}
/**
開發者ID:bg6aer,項目名稱:ckan-php-manager,代碼行數:31,代碼來源:socrata_log_redirects.php


注:本文中的Writer::writeRow方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。