offline2online_fm.py 878 B

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env python
  2. # coding=utf-8
  3. import argparse
  4. def format_model(input_file, output_file):
  5. out_fp = open(output_file, 'w')
  6. with open(input_file) as in_fp:
  7. index = 0
  8. for line in in_fp:
  9. index += 1
  10. line = line.strip()
  11. cells = line.split(' ')
  12. if index == 1:
  13. cells = cells[:2]
  14. else:
  15. cells = cells[:10]
  16. new_line = '%s\n' % '\t'.join(cells)
  17. out_fp.write(new_line)
  18. out_fp.close()
  19. if __name__ == "__main__":
  20. parser = argparse.ArgumentParser()
  21. parser.add_argument('--input', required=True, type=str, help='input file')
  22. parser.add_argument('--output', required=True, type=str, help='output file')
  23. args = parser.parse_args()
  24. print('\n\n')
  25. print(args)
  26. print('\n\n')
  27. format_model(args.input, args.output)