Dumps all records to a CSV file.  If no filename is given then CSV is
 output to STDOUT.

 @param [optional String] path Defaults to STDOUT
325168
def to_csv(path = nil)
      out_io = path ? File.open(path, 'w') : $stdout
      csv = CSV.new(out_io, force_quotes: true)
      csv << column_names
      each { |record| csv << record.to_a }
    end
1150403
def dump(obj, name, path=None, ext="dat", overwrite=True, silent=False):
    
    if path and os.path.isfile(path):
        raise ValueException("Specified path is a file.")

    filename = __get_filename(path, name, ext)
    
    if not overwrite and os.path.exists(filename):
        if not silent:
            raise ValueException("Specified output filename already exists.")
        return
    
    with open(filename, "wb") as f:
        pickle.dump(obj, f)
713562
def save(path)
      update
      Zip::OutputStream.open(path) do |out|
        zip.each do |entry|
          next unless entry.file?
          out.put_next_entry(entry.name)

          if @replace[entry.name]
            out.write(@replace[entry.name])
          else
            out.write(zip.read(entry.name))
          end
        end
      end
      zip.close
    end
1257465
def serialize(path, data)
      # Make a path to the data file if one doesn't already exist
      mkpath_to path

      File.open(path, "w") do |f|
        f.puts data.to_json
      end
    end
789001
def dumps(self):
        """"""

        ret_str = self.path_type

        if self.options is not None:
            ret_str += self.options.dumps()

        return ret_str
1172292
def writeCsv(self, path):
    
    self._createConfluence()
    with open(path, "w") as outputFile:
      writer = csv.writer(outputFile)
      headers = self.getStreamIds()
      fieldNames = ["timestamp"] + headers
      flags = ["T"] + ["" for h in headers]
      types = ["datetime"] + self._confluence.getDataTypes()
      writer.writerow(fieldNames)
      writer.writerow(types)
      writer.writerow(flags)
      for row in self._confluence:
        writer.writerow(row)
    print "Wrote CSV data to %s." % path
767563
function LogfileOutput(path) {

    this._path = path;

    var options = {
        flags: "w",
        mode: 0600
    };

    FS.writeFileSync(this._path, "");

/* TODO
    if (!this._fp) {
        throw new FileCreationFailed("Could not open file " + path);
    }
*/
}
475635
protected void cleanFile(String path) {
		try {
			PrintWriter writer;
			writer = new PrintWriter(path);
			writer.print("");
			writer.close();
		} catch (FileNotFoundException e) {
			throw new RuntimeException("An error occurred while cleaning the file: " + e.getMessage(), e);
		}
	}
1213815
def save(output_path)
      output_path = File.expand_path(output_path)

      create_epub do
        mimetype = Zip::ZipOutputStream::open(output_path) do |os|
          os.put_next_entry("mimetype", nil, nil, Zip::ZipEntry::STORED, Zlib::NO_COMPRESSION)
          os << "application/epub+zip"
        end
        zipfile = Zip::ZipFile.open(output_path)
        Dir.glob('**/*').each do |path|
          zipfile.add(path, path)
        end
        zipfile.commit
      end
      FileUtils.remove_entry_secure dir
    end
718755
def upload_file(file_name, file_path, callback_method='parse')
      status = {}
      upload_config
      @file_name          = file_name
      @file_path          = file_path      
      @original_zip_file  = "#{@file_path}/#{@file_name}"
      @csv_file_name      = @file_name.gsub(/\.zip/,'')

      begin
        if @zipped
          delete_csv_if_present
          unzip_file
        end
        
        status = self.send(callback_method)
      rescue Exception =>  e
        error_in_upload([[invalid_file_message]]) if @error_file_needed
        Rails.logger.error e.formatted_exception("Uploading file #{@file_name} failed!")
        status = { errors: 1, status: 500}
      ensure
        File.delete @original_zip_file if File.exists?(@original_zip_file)
      end
      status
    end
161467
public boolean serializeTo(String path)
    {
        ObjectOutputStream out = null;
        try
        {
            out = new ObjectOutputStream(IOUtil.newOutputStream(path));
            out.writeObject(this);
        }
        catch (Exception e)
        {
//            e.printStackTrace();
            return false;
        }
        return true;
    }
1357519
def dump(self, path):
        
        try:
            with open(path, "wb") as f:
                f.write(self.__str__().encode("utf-8"))
        except:
            pass

        with open(path, "wb") as f:
            pickle.dump(self.__data__, f)
58590
public void writeToFile(String path) {
        try {
            try (OutputStream os = new FileOutputStream(path)) {
                InputStreams.transferTo(body(), os);
            }
        } catch (IOException e) {
            throw new RequestsException(e);
        } finally {
            close();
        }
    }
70436
def dump_to_path(self, cnf, filepath, **kwargs):
        
        _not_implemented(self, cnf, filepath, **kwargs)
583854
def write_to_file(self, file_path: str) -> None:
        
        data = self.encode()
        with open(file_path, "w") as f:
            json.dump(data, f, indent=1)
836214
def logToFile(path, level=logging.INFO):
    
    logger = logging.getLogger()
    logger.setLevel(level)
    formatter = logging.Formatter(
        '%(asctime)s %(name)s %(levelname)s %(message)s')
    handler = logging.FileHandler(path)
    handler.setFormatter(formatter)
    logger.addHandler(handler)
348194
def output path, do_file_close = true
      FileUtils.cp @file.path, path
      close if do_file_close
      self
    end