Another quick and dirty CSV export (local). Dumps all values into a single file
501139
public static void exportStringLocal(File outputFile, JavaRDD<String> data, int rngSeed) throws Exception {
        List<String> linesList = data.collect(); //Requires all data in memory
        if (!(linesList instanceof ArrayList))
            linesList = new ArrayList<>(linesList);
        Collections.shuffle(linesList, new Random(rngSeed));

        FileUtils.writeLines(outputFile, linesList);
    }
886857
def csv_dumper(**kwargs):
    """"""
    logging.info("dumping to csv")
    barn = kwargs["barn"]
    farms = kwargs["farms"]
    experiments = kwargs["experiments"]
    for experiment, farm in zip(experiments, farms):
        name = experiment.journal.name
        project = experiment.journal.project
        project_dir, batch_dir, raw_dir = \
            experiment.journal.paginate()
        if batch_dir is None:
            logging.info("have to generate folder-name on the fly")
            out_data_dir, project_dir, batch_dir, raw_dir = \
                generate_folder_names(name, project)

        if barn == "batch_dir":
            out_dir = batch_dir
        elif barn == "project_dir":
            out_dir = project_dir
        elif barn == "raw_dir":
            out_dir = raw_dir
        else:
            out_dir = barn

        for animal in farm:
            file_name = os.path.join(
                out_dir, "summary_%s_%s.csv" % (
                    animal.name,
                    name
                )
            )
            logging.info(f"> {file_name}")
            animal.to_csv(file_name, sep=prms.Reader.sep)
112380
public static long exportCSV(final Writer out, final ResultSet rs, final long offset, final long count, final boolean writeTitle, final boolean quoted)
            throws UncheckedSQLException, UncheckedIOException {
        return exportCSV(out, rs, null, offset, count, writeTitle, quoted);
    }
27374
def dump_as_two_item_tsv(record, output_file):
    
    for ordered_stats in record.ordered_statistics:
        if len(ordered_stats.items_base) != 1:
            continue
        if len(ordered_stats.items_add) != 1:
            continue
        output_file.write('{0}\t{1}\t{2:.8f}\t{3:.8f}\t{4:.8f}{5}'.format(
            list(ordered_stats.items_base)[0], list(ordered_stats.items_add)[0],
            record.support, ordered_stats.confidence, ordered_stats.lift,
            os.linesep))
1056734
function csv2json(csvData) {
  var result = {};
  var csvLines = csvData.toString().split('\n');
  for (var i in csvLines) {
    var fields = splitCsvLine(csvLines[i]);
    if (fields.length) {
      var key = '';
      for (var k = 0; k < fields.length - 1; k++) {
        if (fields[k].length) {
          key += '.' + fields[k];
        }
      }
      result[key.substr(1)] = fields[fields.length - 1];
    }
  }
  return result;
}
1136046
def save_csv(self, csv_location):  # type: (str) -> None
        
        with open(csv_location, 'w') as csv_handle:
            writer = csv.writer(csv_handle)
            for row in self.csv_data:
                writer.writerow(row)
358436
public static long exportCSV(final File out, final Connection conn, final String querySQL, final long offset, final long count, final boolean writeTitle,
            final boolean quoted) throws UncheckedSQLException, UncheckedIOException {
        return exportCSV(out, conn, querySQL, null, offset, count, writeTitle, quoted);
    }
524022
def dump(self, fileobj):
        ''''''
        if self.file_format == 'csv':
            csv.writer(fileobj).writerows(self.raw_dict().items())
        elif self.file_format == 'json':
            json.dump(self.raw_dict(), fileobj, separators=(',', ':'))
        elif self.file_format == 'pickle':
            pickle.dump(dict(self.raw_dict()), fileobj, 2)
        else:
            raise NotImplementedError('Unknown format: ' +
                                      repr(self.file_format))
241349
def _dump(file_obj, options, out=sys.stdout):
    """"""
    # writer and keys are lazily loaded. We don't know the keys until we have
    # the first item. And we need the keys for the csv writer.
    total_count = 0
    writer = None
    keys = None
    for row in DictReader(file_obj, options.col):
        if not keys:
            keys = row.keys()
        if not writer:
            writer = csv.DictWriter(out, keys, delimiter=u'\t', quotechar=u'\'', quoting=csv.QUOTE_MINIMAL) \
                if options.format == 'csv' \
                else JsonWriter(out) if options.format == 'json' \
                else None
        if total_count == 0 and options.format == "csv" and not options.no_headers:
            writer.writeheader()
        if options.limit != -1 and total_count >= options.limit:
            return
        row_unicode = {k: v.decode("utf-8") if isinstance(v, bytes) else v for k, v in row.items()}
        writer.writerow(row_unicode)
        total_count += 1
9541
def DumpAsCSV (self, separator=",", file=sys.stdout):
                """"""
                for row in range(1, self.maxRow + 1):
                        sep = ""
                        for column in range(1, self.maxColumn + 1):
                                file.write("%s\"%s\"" % (sep, self.GetCellValue(column, row, "")))
                                sep = separator
                        file.write("\n")
691941
def cli(*args, **kwargs):
    
    # Convert CSV file
    content = convert.convert(kwargs["input_file"], **kwargs)

    # Serve the temporary file in browser.
    if kwargs["serve"]:
        convert.serve(content)
    # Write to output file
    elif kwargs["output_file"]:
        # Check if file can be overwrite
        if (not kwargs["overwrite"] and
                not prompt_overwrite(kwargs["output_file"])):
            raise click.Abort()

        convert.save(kwargs["output_file"], content)
        click.secho("File converted successfully: {}".format(
            kwargs["output_file"]), fg="green")
    else:
        # If its not server and output file is missing then raise error
        raise click.BadOptionUsage("Missing argument \"output_file\".")
741583
def convert(csv, json, **kwargs):
    '''
    '''

    csv_local, json_local = None, None
    try:
        if csv == '-' or csv is None:
            csv = sys.stdin
        elif isinstance(csv, str):
            csv = csv_local = open(csv, 'r')

        if json == '-' or json is None:
            json = sys.stdout
        elif isinstance(json, str):
            json = json_local = open(json, 'w')

        data = load_csv(csv, **kwargs)
        save_json(data, json, **kwargs)
    finally:
        if csv_local is not None:
            csv_local.close()
        if json_local is not None:
            json_local.close()
1052345
def csv(self, **kwargs):
        
        out = StringIO()
        writer = csv.DictWriter(out, self.columns, **kwargs)
        writer.writerow(dict(zip(self.columns, self.columns)))
        writer.writerows(dict(row.items()) for row in self.rows)
        
        return out
790734
def dump_all(data_list, stream=None, **kwargs):
    
    return yaml.dump_all(
        data_list,
        stream=stream,
        Dumper=YAMLDictDumper,
        **kwargs
    )
1164662
def export_cscope(file, _path_prefix)
      buf = ''
      files = []
      db_by_line.each do |filename, lines|
        next if lines.empty?

        buf << "\t@#{filename}\n\n"
        buf << "0 #{CSCOPE_GLOBAL_HACK_START}\n"
        files << filename
        func_count = 0

        lines.sort.each do |line_no, records|
          line = line_for_record(records.first)
          toks = tokenize_line(line, records)
          next if toks.empty?

          prev = 0
          buf << line_no.to_s << ' '
          toks.each do |offset, record|
            next if offset < prev # this probably indicates an extractor bug

            # Don't export nested functions, cscope barfs on them since C doesn't
            # have them at all. Skipping tokens is easy; since prev isn't updated
            # they get turned into plain text automatically.
            if record[:type] == :func
              case record[:tbl]
              when :defs
                func_count += 1
                next unless func_count == 1
              when :end
                func_count -= 1
                next unless func_count == 0
              end
            end

            buf << cscope_output(line, prev, offset, record)
            prev = offset + record[:key].length
          end
          buf << cscope_plaintext(line, prev, line.length) << "\n\n"
        end
      end

      buf << "\t@\n"

      header = "cscope 15 #{Dir.pwd} -c "
      offset = format("%010d\n", header.length + 11 + buf.bytes.count)

      file.print(header)
      file.print(offset)
      file.print(buf)

      file.print("#{@meta[:paths].length}\n")
      @meta[:paths].each { |p| file.print("#{p}\n") }
      file.print("0\n")
      file.print("#{files.length}\n")
      buf = ''
      files.each { |f| buf << f + "\n" }
      file.print("#{buf.length}\n#{buf}")
    end
567160
def dump(data, stream=None, **kwargs):
    
    return yaml.dump_all(
        [data],
        stream=stream,
        Dumper=YAMLDictDumper,
        **kwargs
    )
170228
function csv(array)
	{
		if (!(array instanceof Array) || array.length === 0)
			return '';

		array = array.slice(0);

		var i = array.length;
		while (i--)
			array[i] = '"' + (''+array[i]).replace(/(\\|")/g, '\\$1') + '"';

		return array.join(', ');
	}