Writes all results to one file for future splitting.
 @param file_name [String] name of the local export file
 @return [Integer] number of records to export.
2940
def write_csv(file_name, records)
      line_number = exporter.connection_adapter.write(local_file(file_name), records)
    end
467129
def print_data_to_file(data, file_name):
    
    try:
        with open(file_name, 'w') as output_file:
            print >>output_file, "\t".join(data.dtype.names)
            for row in data:
                print >>output_file, "\t".join(map(str, row))
    except IOError:
        msg = "{}: can't write file".format(file_name)
        raise ProgramError(msg)
865741
def write(self, filename, type_='obo'):  #FIXME this is bugged
        
        if os.path.exists(filename):
            name, ext = filename.rsplit('.',1)
            try:
                prefix, num = name.rsplit('_',1)
                n = int(num)
                n += 1
                filename = prefix + '_' + str(n) + '.' + ext
            except ValueError:
                filename = name + '_1.' + ext
            print('file exists, renaming to %s' % filename)
            self.write(filename, type_)

        else:
            with open(filename, 'wt', encoding='utf-8') as f:
                if type_ == 'obo':
                    f.write(str(self))  # FIXME this is incredibly slow for big files :/
                elif type_ == 'ttl':
                    f.write(self.__ttl__())
                else:
                    raise TypeError('No exporter for file type %s!' % type_)
1116592
def save_to_wav(self, file_name):
        
        scaled = _numpy.int16(self.numpy()/max(abs(self)) * 32767)
        write_wav(file_name, self.sample_rate, scaled)
194521
public function write($file_name, $content = '')
    {
        if (!is_file($file_name)) {
            return false;
        }

        return file_put_contents($file_name, $content, LOCK_EX);
    }
1244277
def count_with_file(filename)
      return if ::ServiceMock.disable_stubs
      yield self if block_given?
      content = File.open(filename, 'rb') { |file| file.read }
      count(content)
    end
1335596
def create_file(self, name: str, generate_unique_name: bool = False):
        '''
        
        '''
        def enumerate_name():
            yield name
            index = 0
            while True:
                index += 1
                yield f'{name} ({index})'
        for n in enumerate_name():
            path = os.path.join(self._path, n)
            if os.path.exists(path):
                if not generate_unique_name:
                    raise FileExistsError
            return FileInfo(path)
498521
def output_filename(name)
      path = File.expand_path(name, output_dir)
      output File.new(path, 'a+')
    end
769167
def write_to(filename)
      FileUtils.mkdir_p File.dirname(filename)

      PathUtils.atomic_write(filename) do |f|
        f.write source
      end

      nil
    end
1055349
def file(name, &block)
      path = @path + name
      unless ::File.file?(path)
        FileUtils.touch(path)
        @ctx.add(path)
      end
      f = File.new(@ctx, path)
      f.instance_eval(&block) if block_given?
      f
    end
1082287
private void writeToFile(MemoryCommitResult mcr) {
        // Rename the current file so it may be used as a backup during the next read
        if (mFile.exists()) {
            if (!mcr.changesMade) {
                // If the file already exists, but no changes were
                // made to the underlying map, it's wasteful to
                // re-write the file.  Return as if we wrote it
                // out.
                mcr.setDiskWriteResult(true);
                return;
            }
            if (!mBackupFile.exists()) {
                if (!mFile.renameTo(mBackupFile)) {
                    System.out.println( "Couldn't rename file " + mFile
                            + " to backup file " + mBackupFile);
                    mcr.setDiskWriteResult(false);
                    return;
                }
            } else {
                mFile.delete();
            }
        }

        // Attempt to write the file, delete the backup and return true as atomically as
        // possible.  If any exception occurs, delete the new file; next time we will restore
        // from the backup.
        try {
            FileOutputStream str = createFileOutputStream(mFile);
            if (str == null) {
                mcr.setDiskWriteResult(false);
                return;
            }
            XmlUtils.writeMapXml(mcr.mapToWriteToDisk, str);
            FileUtils.sync(str);
            str.close();
            setFilePermissionsFromMode(mFile.getPath(), mMode, 0);
            if (mFile.canRead()) {
                synchronized (this) {
                    mStatTimestamp = mFile.lastModified();
                    mStatSize = mFile.length();
                }
            }
            // Writing was successful, delete the backup file if there is one.
            mBackupFile.delete();
            mcr.setDiskWriteResult(true);
            return;
        } catch (IOException e) {
            System.out.println("writeToFile: Got exception:" + e);
        }
        // Clean up an unsuccessfully written file
        if (mFile.exists()) {
            if (!mFile.delete()) {
                System.out.println("Couldn't clean up partially-written file " + mFile);
            }
        }
        mcr.setDiskWriteResult(false);
    }
1175918
def get_new_file_writer(file)
      if File.extname(file) == '.gz'
        Zlib::GzipWriter.new(File.new(file, 'wb'))
      else
        File.new(file, 'wb')
      end
    end
1001742
def print_or_write(data)
      if opts[:output_file]
        File.open(opts[:output_file], "w") { |f| f.write(data) }
      else
        puts data
      end
    end
1328832
def write_results(filename,config,srcfile,samples):
     
    results = createResults(config,srcfile,samples=samples)
    results.write(filename)
278739
def file(name)
      File.open(name, "rb") {|f|
        buf = ""
        while f.read(16384, buf)
          update buf
        end
      }
      self
    end
244130
def load(self, file_name):
        

        new_rundata = self.loader(file_name)
        new_rundata = self.inspect(new_rundata)
        return new_rundata
1125595
def file(name)
      files.find {|file| file.file_ref.name == name or file.file_ref.path == name  }
    end