Skip to main content

Python module containing various functions

Project description

rkpython

Description

This is a general use Python module. For now, it only contains some functions to make reading and writing to text files easier, as well as a function that returns information for reading csv files**.

Installation

Use

pip install rkpython

Then import it in Python with

import rkpython as rk

Functions

to_txt()

rk.to_txt(l=None, path='text_file.txt', overwrite=False, verbose = False)	

--------------  

Saves a list to a .txt file.  

l : list, default is None  
	List object to be saved.  

path : str, default is 'text_file.txt'  
	File path (with file name) you want to save to.    

overwrite : bool, default is False    
	Overwrites the file if it exists.  

verbose : boolean, default is False  
	Prints out a message if the operation was succesful  

--------------  

Examples :  

rk.to_txt(var_list, './documents/vars.txt', verbose = True)  
>> File successfully written to ./documents/vars.txt 

read_txt()

rk.read_txt(path='text_file.txt', verbose = False)    

--------------  

Reads from a text file, saving the result as a list, where each line is one item.  


path : str, default = 'text_file.txt'  
	File path (with file name) you want to read from. Can be any type of file (.txt, .csv...)    

verbose : boolean, default is False  
	Prints out a message if the operation was succesful  

--------------  

Examples :  

var_list = rk.read_txt('./documents/vars.txt', verbose = True)  
>> File successfully read from ./documents/vars.txt  

to_size()

def to_size(size_in_bytes):

Converts a number of bytes into a more readable unit, up until Terabytes, and rounds the number down to 1 decimal. Returns a string.

--------------

size_in_bytes : int
    Size in bytes that needs to be converted

--------------

Examples :

get_size(124480000)
>> '124.5 Mb'

rk.get_mem()

def get_mem(nb_objects = 10):

Prints out a list of the largest objects stored in memory, as well as the total memory usage of global variables. Returns a string.

--------------

nb_objects : int, default =  10
    Maximum number of items to be printed out.

--------------

Examples :

get_mem(5)
>> Total usage : 25.3 Gb
>>
>>  5 largest objects :
>>  _477  :  1.7 Gb
>>  _529  :  1.7 Gb
>>  _437  :  1.4 Gb
>>  _412  :  1.3 Gb
>>  _415  :  1.3 Gb

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rkpython-0.0.19.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rkpython-0.0.19-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file rkpython-0.0.19.tar.gz.

File metadata

  • Download URL: rkpython-0.0.19.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.4

File hashes

Hashes for rkpython-0.0.19.tar.gz
Algorithm Hash digest
SHA256 57586a338e425ce7c0ae8fcea5ce5f9048203cc4498ba8b36fdcc32ae8ea8fad
MD5 6709cb21742c37765cf847ec71117821
BLAKE2b-256 7c72a2307471238566a064dcb99bc1ee9f4485922f8d3954c25eef70bdff7b73

See more details on using hashes here.

File details

Details for the file rkpython-0.0.19-py3-none-any.whl.

File metadata

  • Download URL: rkpython-0.0.19-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.4

File hashes

Hashes for rkpython-0.0.19-py3-none-any.whl
Algorithm Hash digest
SHA256 226f6bb3094492293214789013caf05c08ad07c07cb08844cda19369664fa995
MD5 7203c8ebd0a3b6dc15069a19452cfa48
BLAKE2b-256 6fc37369e13dd22282de16819fe21b915ae2497176594c477ea28c5fb27e03be

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page