(original_file, new_file, scale_rate)
Scale data file.
Scale data file.
Scale data file .
def scale_data(original_file, new_file, scale_rate):
  """Scale data file."""
  logging.info("Scale file from {} to {}".format(original_file, new_file))

  with open(original_file, encoding="utf-8") as original_f, \
    open(new_file, "w", encoding="utf-8") as new_f:

    original_lines = original_f.readlines()
    original_size = len(original_lines)
    new_size = int(original_size * scale_rate)

    for i, line in enumerate(data_generator(original_lines)):
      if i >= new_size:
        break
      new_f.write(line)
def scale_data ( original_file , new_file , scale_rate ) : logging . info ( "Scale file from {} to {}" . format ( original_file , new_file ) ) with open ( original_file , encoding = "utf-8" ) as original_f , open ( new_file , "w" , encoding = "utf-8" ) as new_f : original_lines = original_f . readlines ( ) original_size = len ( original_lines ) new_size = int ( original_size * scale_rate ) for i , line in enumerate ( data_generator ( original_lines ) ) : if i >= new_size : break new_f . write ( line )