Phone

+919997782184

Email

support@roboticswithpython.com

Geeks of Coding

Join us on Telegram

Home Forums Cody Bank doc to Unix

Tagged: 

Viewing 0 reply threads
  • Author
    Posts
    • #978
      Sahil KumarSahil Kumar
      Moderator

      https://github.com/ghostman-ai/doc-to-Unix.git

      #!/usr/bin/env python
      # coding: utf-8
      
      # In[1]:
      
      """
      convert dos linefeeds (crlf) to unix (lf)
      usage: dos2unix.py 
      """
      original = "final_project_dataset.pkl"
      destination = "final_project_dataset_unix.pkl"
      
      content = ''
      outsize = 0
      with open(original, 'rb') as infile:
          content = infile.read()
      with open(destination, 'wb') as output:
          for line in content.splitlines():
              outsize += len(line) + 1
              output.write(line + str.encode('\n'))
      
      print("Done. Saved %s bytes." % (len(content)-outsize))
Viewing 0 reply threads
  • You must be logged in to reply to this topic.