elisa-aleman / useful_methods

Useful methods I like to import to save time. I stopped using a lot of them when I started using pandas, but the ProjectPaths.py I use frequently

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Useful Methods

Useful methods I like to import to save time. I stopped using a lot of them when I started using pandas, but the ProjectPaths.py I use frequently.

Special printing methods

  • up() : Go up a line in the terminal to print over something
  • down() : Go down a line in the terminal
  • print_STD_log(strlog, log_file) : Print string to terminal and to file at the same time
  • print_log(strlog, log_file) : Print string to a file
  • print_list_to_log(strlist, log_file) : Print list of strings to a file
  • print_list_to_STD_log(strlist, log_file) : Print list of strings to the terminal and to a file at the same time
  • write_tuple_list_to_csv(ins_table, filepath) : Write tuple list to CSV file
  • append_tuple_to_csv(ins_tuple, filepath) : Append tuple to CSV file

Data organizing methods

  • tail(filepath, decode_utf8=True, with_head=True, pandas_read=True) : Returns the last line in a file
  • head(filepath, decode_utf8=True) : Returns the first line in a file
  • line_count_rawgen(filepath, last_index_csv=True) : Fast way to count lines in a file
  • read_dict(filename) : Get a word list text file (a word per line) into a list
  • flatten(container) : Make a list like [1,[2,3],[4,[5]]] into [1,2,3,4,5]

CSV and SQL

  • CSVcreateSQL(titles, dbname, tablename) : create empty SQL table from a csv file column titles
  • CSVtoSQL(titles, table, dbname, tablename) : copy csv into the created SQL table
  • SQLtoCSV(dbname) : make a csv by table from a SQL database

About

Useful methods I like to import to save time. I stopped using a lot of them when I started using pandas, but the ProjectPaths.py I use frequently

License:MIT License


Languages

Language:Python 100.0%