当前位置: 首页>>代码示例>>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;未经允许,请勿转载。