2020-08-08
UCS-2 is UTF-16, really, for any codepoint that was assigned when it was still called UCS-2 in any case.
Open it with encoding='utf16'. If there is no BOM (the Byte order mark, 2 bytes at the start, for BE that'd be \xfe\xff), then use encoding='utf_16_be' to force a byte order.
From <https://stackoverflow.com/questions/14488346/python-3-reading-ucs-2-be-file>
There is a useful package in Python - chardet, which helps to detect the encoding used in your file. Actually there is no program that can say with 100% confidence which encoding was used - that's why chardet gives the encoding with the highest probability the file was encoded with. Chardet can detect following encodings:
• ASCII, UTF-8, UTF-16 (2 variants), UTF-32 (4 variants)
• Big5, GB2312, EUC-TW, HZ-GB-2312, ISO-2022-CN (Traditional and Simplified Chinese)
• EUC-JP, SHIFT_JIS, CP932, ISO-2022-JP (Japanese)
• EUC-KR, ISO-2022-KR (Korean)
• KOI8-R, MacCyrillic, IBM855, IBM866, ISO-8859-5, windows-1251 (Cyrillic)
• ISO-8859-2, windows-1250 (Hungarian)
• ISO-8859-5, windows-1251 (Bulgarian)
• windows-1252 (English)
• ISO-8859-7, windows-1253 (Greek)
• ISO-8859-8, windows-1255 (Visual and Logical Hebrew)
• TIS-620 (Thai)
From <https://riptutorial.com/encoding/example/23227/how-to-detect-the-encoding-of-a-text-file-with-python→
You can install chardet with a pip command:
pip install chardet
mport chardet
rawdata = open(file, “rb”).read()
result = chardet.detect(rawdata)
charenc = result['encoding']
From <https://riptutorial.com/encoding/example/23227/how-to-detect-the-encoding-of-a-text-file-with-python→
From <https://riptutorial.com/encoding/example/23227/how-to-detect-the-encoding-of-a-text-file-with-python→
2020-07-16
Atrribute errno is defined only in OSError and classes inheriting from it.
So apparently line 88 is part of try…except clause and in that line you're trying to use e.errno. You can't do that if the exception doesn't belong to OSError exceptions family.
From <https://stackoverflow.com/questions/48541077/exceptions-runtimeerror-object-has-no-attribute-errno>
2020-07-05
Cclasses
Make an empty file called init.py in the same directory as the files. That will signify to Python that it's “ok to import from this directory”.
From <https://stackoverflow.com/questions/4142151/how-to-import-the-class-within-the-same-directory-or-sub-directory>
Same as previous, but prefix the module name with a . if not using a subdirectory:
from .user import User
from .dir import Dir
From <https://stackoverflow.com/questions/4142151/how-to-import-the-class-within-the-same-directory-or-sub-directory>
Python 3.3+ has Implicit Namespace Packages that allow it to create a packages without an init.py file.
Allowing implicit namespace packages means that the requirement to provide an __init__.py file can be dropped completely, and affected .
From <https://stackoverflow.com/questions/37139786/is-init-py-not-required-for-packages-in-python-3-3>
PEP 420 – Implicit Namespace Packages
From <https://www.python.org/dev/peps/pep-0420/>
2020-07-04
Python RegEx
❮ PreviousNext ❯
A RegEx, or Regular Expression, is a sequence of characters that forms a search pattern.
RegEx can be used to check if a string contains the specified search pattern.
RegEx Module
Python has a built-in package called re, which can be used to work with Regular Expressions.
Import the re module:
From <https://www.w3schools.com/python/python_regex.asp>
2020-04-02
RAW DATA
https://datasetsearch.research.google.com/
Discovering millions of datasets on the web
Natasha Noy
Research Scientist, Google Research
Published Jan 23, 2020
Across the web, there are millions of datasets about nearly any subject that interests you. If you’re looking to buy a puppy, you could find datasets compiling complaints of puppy buyers or studies on puppy cognition. Or if you like skiing, you could find data on revenue of ski resorts or injury rates and participation numbers. Dataset Search has indexed almost 25 million of these datasets, giving you a single place to search for datasets and find links to where the data is. Over the past year, people have tried it out and provided feedback, and now Dataset Search is officially out of beta.
From <https://blog.google/products/search/discovering-millions-datasets-web/?utm_source=hackernewsletter&utm_medium=email&utm_term=data>
2020-04-01
Comprehensive Python Cheatsheet
Contents
1. Collections: List, Dictionary, Set, Tuple, Range, Enumerate, Iterator, Generator.
2. Types: Type, String, Regular_Exp, Format, Numbers, Combinatorics, Datetime.
3. Syntax: Args, Inline, Closure, Decorator, Class, Duck_Type, Enum, Exception.
4. System: Exit, Print, Input, Command_Line_Arguments, Open, Path, OS_Commands.
5. Data: JSON, Pickle, CSV, SQLite, Bytes, Struct, Array, Memory_View, Deque.
6. Advanced: Threading, Operator, Introspection, Metaprograming, Eval, Coroutines.
7. Libraries: Progress_Bar, Plot, Table, Curses, Logging, Scraping, Web, Profile,
NumPy, Image, Audio, Pygame.
From <https://github.com/gto76/python-cheatsheet?utm_source=hackernewsletter&utm_medium=email&utm_term=code>
2020-01-19
Illustrated Guide to Python 3: A Complete Walkthrough of Beginning Python with Unique Illustrations Showing how Python Really Works. Now covering Python 3.6 (Treading on Python) (Volume 1) 2nd Edition
From <https://www.amazon.com/Illustrated-Guide-Python-Walkthrough-Illustrations/dp/1977921752?SubscriptionId=AKIAIGH7TZJVBZLN4QSQ&tag=peterbecom-20&linkCode=xm2&camp=2025&creative=165953&creativeASIN=1977921752>
2019-09–17
Retrieve all groups for a domain or the account
To retrieve all groups for a specific domain or the account, use the following GET request and include the authorization described in Authorize requests. For the query strings, request, and response properties, see the API Reference. For readability, this example uses line returns:
GET https://www.googleapis.com/admin/directory/v1/groups?domain=domain name
&customer=my_customer or customerId&pageToken=pagination token
&maxResults=max results
When retrieving:
• All groups for a sub-domain — Use the domain argument with the domain's name.
• All groups for the account — Use the customer argument with either my_customer or the account's customerIdvalue. As an account administrator, use the string my_customer to represent your account's customerId. If you are a reseller accessing a resold customer's account, use the resold account's customerId. For the customerIdvalue use the account's primary domain name in the Retrieve all users in a domain operation's request. The resulting response has the customerId value.
• Using both domain and customer arguments — The API returns all the groups for the domain.
• Not using the domain and customer arguments — The API returns all the groups for the account associated with my_customer. This is the account customerId of the administrator making the API request.
From <https://developers.google.com/admin-sdk/directory/v1/guides/manage-groups>
APIs & Services
Google API Dashboard
From <https://console.developers.google.com/apis/dashboard?project=quickstart-1566368013602&authuser=0&pli=1>
API s Explorer
Learn more about using the Groups Settings API by reading the documentation.
From <https://developers.google.com/apis-explorer/#p/groupssettings/v1/>
Google API Client
This is the Python client library for Google's discovery based APIs. To get started, please see the docs folder.
These client libraries are officially supported by Google. However, the libraries are considered complete and are in maintenance mode. This means that we will address critical bugs and security issues but will not add any new features.
Installation
To install, simply use pip or easy_install:
pip install –upgrade google-api-python-client
From <https://github.com/googleapis/google-api-python-client>
Groups Settings API
Lets you manage permission levels and related settings of a group.
Documentation for the Groups Settings API in PyDoc.
samples/groupssettings Sample for the Groups Settings API
From <https://github.com/googleapis/google-api-python-client/tree/master/samples>
2019-08-28
Algorithms
by Jeff Erickson
🔥1st edition, June 2019 🔥
(Amazon links: US, UK, DE, ES, FR, IT, JP)
This web page contains a free electronic version of my self-published textbook Algorithms, along with other lecture notes I have written for various theoretical computer science classes at the University of Illinois, Urbana-Champaign since 1998.
From <http://jeffe.cs.illinois.edu/teaching/algorithms/#book>
2019-08-23
You can still miss attachments by following @Ilya V. Schurov or @Cam T answers, the reason is because the email structure can be different based on the mimeType.
From <https://stackoverflow.com/questions/25832631/download-attachments-from-gmail-using-gmail-api>
Gmail API: where to find body of email depending of mimeType
From <https://stackoverflow.com/questions/37445865/gmail-api-where-to-find-body-of-email-depending-of-mimetype#37463491>
• Now with this service you can read your emails and read any attachments you may have in your e-mails
• First you can query your e-mails with a search string to find the e-mail ids you need that have the attachments:
search_query = “ABCD”
result = service.users().messages().list(userId='me', q=search_query).execute()
msgs = results['messages')
msg_ids = [msg['id'] for msg in msgs]
• now for each messageId you can find the associated attachments in the email.
From <https://stackoverflow.com/questions/41749236/download-a-csv-file-from-gmail-using-python>
payload.headers[] list List of headers on this message part. For the top-level message part, representing the entire message payload, it will contain the standard RFC 2822 email headers such as To, From, and Subject.
From <https://developers.google.com/gmail/api/v1/reference/users/messages>
headers=messageheader[“payload”][“headers”]
subject= [i['value'] for i in headers if i["name"]=="Subject"]
From <https://stackoverflow.com/questions/55144261/python-how-to-get-the-subject-of-an-email-from-gmail-api>
the Gmail API
Complete the steps described in the rest of this page to create a simple Python command-line application that makes requests to the Gmail API.
From <https://developers.google.com/gmail/api/quickstart/python#step_4_run_the_sample>
Download Attachments from gmail using Gmail API
Remove all special characters, punctuation and spaces from string
Example 3
import re re.sub('\W+',, string)
• string1 - Result: 3.11899876595
• string2 - Result: 2.78014397621
From <https://stackoverflow.com/questions/5843518/remove-all-special-characters-punctuation-and-spaces-from-string>
Access Dates
and then access the data using a loop:
for msg in msgs['messages']:
m_id = msg['id'] # get id of individual message
message = service.users().messages().get(userId='me', id=m_id).execute()
payload = message['payload']
header = payload['headers']
for item in header:
if item['name'] == 'Date':
date = item['value']
DATA STORAGE FUNCTIONS ETC
From <https://stackoverflow.com/questions/46615395/gmail-api-quickly-access-the-dates-of-every-email-ever-sent-received>
Python's strftime directives
Note: Examples are based on datetime.datetime(2013, 9, 30, 7, 6, 5)
From <http://strftime.org/>
2019-08-22
Python : How to Sort a Dictionary by key or Value ?
From <https://thispointer.com/python-how-to-sort-a-dictionary-by-key-or-value/>
2019-08-15
Interactive Plots with Plotly and Cufflinks on Pandas Dataframes
A simple and easy introduction to interactive visualisation with Plotly in python.
Ozan
Oct 8, 2018 · 4 min read
Pandas is one of the the most preferred and widely used tools in Python for data analysis. It also has it’s own sample build-in plot function. Hovewer when it comes to interactive visualization, Python users face some difficulties if they haven’t front-end engineer skills since lots of library such as D3, chart.js requires some javascript background. This is where that Plotly and Cufflinks come handy.
From <https://medium.com/@ozan/interactive-plots-with-plotly-and-cufflinks-on-pandas-dataframes-af6f86f62d94>
</WRAP>
2019-07-11
Parsing text with Python
2018-01-07 · 2966 words · 14 minute read
python
programming · parsing · python
I hate parsing files, but it is something that I have had to do at the start of nearly every project. Parsing is not easy, and it can be a stumbling block for beginners. However, once you become comfortable with parsing files, you never have to worry about that part of the problem.
From <https://www.vipinajayakumar.com/parsing-text-with-python/>
2019-08-14
Pandas Tutorial: DataFrames in Python
Explore data analysis with Python. Pandas DataFrames make manipulating your data easy, from selecting or replacing columns and indices to reshaping your data.
From <https://www.datacamp.com/community/tutorials/pandas-tutorial-dataframe-python>
2019-7-11
B2 python SDK
Backblaze
This repository contains a client library and a few handy utilities for easy access to all of the capabilities of B2 Cloud Storage.
B2 command-line tool is an example of how it can be used to provide command-line access to the B2 service, but there are many possible applications (including FUSE filesystems, storage backend drivers for backup applications etc).
From <https://github.com/Backblaze/b2-sdk-python/tree/master?utm_campaign=Newsletter-B2&utm_medium=email&_hsenc=p2ANqtz-933CaN9zTTwQD8oSR0sbDcpfTXIqfjs03KzOMqNB9Q9g7grroQTWRtUHD58cdprg1KrCGAIm0wSrQAVXoLWNFlxPlhug&_hsmi=74285577&utm_content=74285577&utm_source=hs_email&hsCtaTracking=1e01a8c6-0568-4a44-b739-4dbbcccda871%7Cc331f25d-0ec0-48b0-8b7d-6a15b9112aec>
Backblaze is making two new APIs available that integrators and customers have been asking for: copy_file and copy_part. Together, the new functionality makes it easier to work with large files and to copy and manipulate files directly in B2.
From <https://mail.google.com/mail/u/0/?zx=lgfx6lxl1rpm#inbox>
2019-07-01
import plotly.plotly as py
import plotly.graph_objs as go
data = [
go.Scatter(
x=[1, 2],
y=[1, 2]
)
]
layout = go.Layout(
xaxis=dict(
autorange='reversed'
)
)
fig = go.Figure(data=data, layout=layout)
py.iplot(fig, filename='axes-reversed')
From <https://plot.ly/python/axes/>
2019-05-29
ValidIpAddressRegex = “^1)
13 with Timer(times2):
14 for i in range(N):
15 sorted_d = sorted(d.items(), key=lambda x: x[1])
16 with Timer(times1):
17 for i in range(N):
18 sorted_d = sorted(d.items(), key=operator.itemgetter(1))
19 with Timer(times4):
20 for i in range(N):
21 sorted_d = [(k,v) for k,v in d.items()]
22 print(j)
23 pylab.boxplot([times1, times2, times3, times4])
24 pylab.xticks([1,2,3,4], [“operator”, “lambda”, “list comprehension and lambda”, “py36”])
25 pylab.ylabel(“Time (seconds) 1 million sorting \n (repeated 20 times)”)
26 pylab.grid()
27 pylab.title(“Performance sorted dictionary by values”)
From <http://thomas-cokelaer.info/blog/2017/12/how-to-sort-a-dictionary-by-values-in-python/>
As already said, iteritems() will be a problem, but you mention a syntax error, which comes from the lambda declaration with parenthesis:
Change:
key=lambda(k, v): sort_order.index(k)
To:
key=lambda k, v: sort_order.index(k)
From <https://stackoverflow.com/questions/47749438/lambda-sorting-in-python-3>
2018-11-15
What problem does pandas solve?
Python has long been great for data munging and preparation, but less so for data analysis and modeling. pandas helps fill this gap, enabling you to carry out your entire data analysis workflow in Python without having to switch to a more domain specific language like R.
From <https://pandas.pydata.org/>
NumPy
NumPy is the fundamental package for scientific computing with Python. It contains among other things:
• a powerful N-dimensional array object
• sophisticated (broadcasting) functions
• tools for integrating C/C++ and Fortran code
• useful linear algebra, Fourier transform, and random number capabilities
From <http://www.numpy.org/>
Array Broadcasting
Broadcasting is the name given to the method that NumPy uses to allow array arithmetic between arrays with a different shape or size.
From <https://machinelearningmastery.com/broadcasting-with-numpy-arrays/>
scikit-learn
Machine Learning in Python
• Simple and efficient tools for data mining and data analysis
• Accessible to everybody, and reusable in various contexts
• Built on NumPy, SciPy, and matplotlib
• Open source, commercially usable - BSD license
From <https://scikit-learn.org/stable/>
Welcome to PyBrain
PyBrain is a modular Machine Learning Library for Python. Its goal is to offer flexible, easy-to-use yet still powerful algorithms for Machine Learning Tasks and a variety of predefined environments to test and compare your algorithms.
From <http://pybrain.org/>
2018-11-06
python read fails on special characters
with io.open(fileToSearch,'r',encoding='utf-8') as file:
From <https://stackoverflow.com/questions/47635759/how-to-read-a-text-file-with-special-characters-in-python>
An unrelated hint: have a look at the built-in function enumerate, which frees you from taking care of incrementing counter: You simply write for counter, line in enumerate(file):
From <https://stackoverflow.com/questions/47635759/how-to-read-a-text-file-with-special-characters-in-python>
2018-10-31
A number of IDEs support menu options to set the execution environment for programs under development and testing. In particular, it would be nice if IDLE let the user set command line arguments to be passed into sys.argv when running a script by pressing F5.
Here are some existing implementations for reference:
* Wing-IDE: https://wingware.com/doc/intro/tutorial-debugging-launch
* Visual Studio: https://www.youtube.com/watch?v=IgbQCRHKV-Y
* PyCharm: https://www.jetbrains.com/pycharm/help/run-debug-configuration-python.html
This feature will help users interactively develop and test command-line tools while retaining all the nice features of the IDE. I would personally find it useful when teaching students about how sys.argv works.
From <https://bugs.python.org/issue5680>
Pending application of a patch, the following will work to only add args to sys.argv when running from an Idle editor.
import sys
# …
if name == 'main':
if 'idlelib.PyShell' in sys.modules:
sys.argv.extend(('a', '-2')) # add your argments here.
print(sys.argv) # in use, parse sys.argv after extending it
# ['C:\\Programs\\python34\\tem.py', 'a', '-2']
From <https://bugs.python.org/issue5680>
try:
__file__
except:
sys.argv = [sys.argv[0], 'argument1', 'argument2', 'argument2']
From <https://stackoverflow.com/questions/2148994/when-running-a-python-script-in-idle-is-there-a-way-to-pass-in-command-line-arg>
2018-10-31
Auto detect IDLE and prompt for command-line argument values
#! /usr/bin/env python3
import sys
def ok(x=None):
sys.argv.extend(e.get().split())
root.destroy()
if 'idlelib.rpc' in sys.modules:
import tkinter as tk
root = tk.Tk()
tk.Label(root, text="Command-line Arguments:").pack()
e = tk.Entry(root)
e.pack(padx=5)
tk.Button(root, text=“OK”, command=ok,
default=tk.ACTIVE).pack(pady=5)
root.bind(“<Return>”, ok)
root.bind("<Escape>", lambda x: root.destroy())
e.focus()
From <https://stackoverflow.com/questions/2148994/when-running-a-python-script-in-idle-is-there-a-way-to-pass-in-command-line-arg/44687632#44687632>
2018-10-30
Python Script
Here's a Python script that will also print the files deleted
import os
for line in open(“./data/deleted.files”):
if line.isspace() or line[0] == '#':
continue
line = line.rstrip(os.linesep)
try:
if os.path.exists(line):
print('File removed => ' + line)
os.remove(line)
except OSError:
pass
Here's an alternative Python script that is case sensitive and will also delete directories included in the list
import os
import shutil
def exists_casesensitive(path):
if not os.path.exists(path):
return False
directory, filename = os.path.split(path)
return filename in os.listdir(directory)
with open(“./data/deleted.files”) as file:
for line in file:
line = line.strip()
if line and not line.startswith('#'):
path = line.rstrip(os.linesep)
if exists_casesensitive(path):
if os.path.isdir(path):
shutil.rmtree(path)
print('Directory removed => ' + path)
else:
os.remove(path)
print('File removed => ' + path)
else:
#print('File not found => ' + path)
pass
From <https://www.dokuwiki.org/install:unused_files>
2018-10-06
GLOB
def delete_previous_checkpoints(self, num_previous=5):
"""
Deletes all previous checkpoints that are <num_previous> before the present checkpoint.
This is done to prevent blowing out of memory due to too many checkpoints
:param num_previous:
:return:
"""
self.present_checkpoints = glob.glob(self.get_checkpoint_location() + '/*.ckpt')
if len(self.present_checkpoints) > num_previous:
present_ids = [self.__get_id(ckpt) for ckpt in self.present_checkpoints]
present_ids.sort()
ids_2_delete = present_ids[0:len(present_ids) - num_previous]
for ckpt_id in ids_2_delete:
ckpt_file_nm = self.get_checkpoint_location() + '/model_' + str(ckpt_id) + '.ckpt'
os.remove(ckpt_file_nm)
From <https://www.programcreek.com/python/example/92/glob.glob>
2018-10-06
If you're doing anything more complicated than a script that accepts a few required positional arguments, you'll want to use a parser. Depending on your python version, there are 3 available in the python standard library (getopt, optparse and argparse) and argparse is by far the best.
From <https://stackoverflow.com/questions/35365344/python-sys-argv-and-argparse>
Argparse Tutorial
author: Tshepang Lekhonkhobe
This tutorial is intended to be a gentle introduction to argparse, the recommended command-line parsing module in the Python standard library.
From <https://docs.python.org/3.7/howto/argparse.html>
*args and kwargs in Python
*args
The special syntax *args in function definitions in python is used to pass a variable number of arguments to a function. It is used to pass a non-keyworded, variable-length argument list.
From <https://www.geeksforgeeks.org/args-kwargs-python/>
2018-10-03
In Python 3.5 and newer use the new recursive / functionality:
configfiles = glob.glob('C:/Users/sam/Desktop/file1//*.txt', recursive=True)
When recursive is set, followed by a path separator matches 0 or more subdirectories.
From <https://stackoverflow.com/questions/14798220/how-can-i-search-sub-folders-using-glob-glob-module-in-python>
for i in d.iglob('/*'):
The “” pattern means “this directory and all subdirectories, recursively”. In other words, it enables recursive globbing:
From <https://docs.python.org/3/library/pathlib.html>
errno.ENOTEMPTY
Directory not empty
From <https://docs.python.org/2/library/errno.html>
errno.EACCES¶
Permission denied
From <https://docs.python.org/2/library/errno.html>
except OSError as e:
if e.errno not in _IGNORED_ERROS:
raise
return False
From <https://github.com/python/cpython/blob/3.7/Lib/pathlib.py>
except OSError as e:
if e.errno != EINVAL and strict:
raise
From <https://github.com/python/cpython/blob/3.7/Lib/pathlib.py>
2018-10-01
import os, sys
from stat import *
def walktree(top, callback):
'''recursively descend the directory tree rooted at top,
calling the callback function for each regular file'''
for f in os.listdir(top):
pathname = os.path.join(top, f)
mode = os.stat(pathname).st_mode
if S_ISDIR(mode):
# It's a directory, recurse into it
walktree(pathname, callback)
elif S_ISREG(mode):
# It's a file, call the callback function
callback(pathname)
else:
# Unknown file type, print a message
print('Skipping %s' % pathname)
def visitfile(file):
print('visiting', file)
if name == 'main':
walktree(sys.argv[1], visitfile)
From <https://docs.python.org/3/library/stat.html>
2018-09-29
Dropbox in python
from pathlib import Path
import arrow
filesPath = r“C:\scratch\removeThem”
criticalTime = arrow.now().shift(hours=+5).shift(days=-7)
for item in Path(filesPath).glob('*'):
if item.is_file():
print (str(item.absolute()))
itemTime = arrow.get(item.stat().st_mtime)
if itemTime < criticalTime:
#remove it
pass
From <https://stackoverflow.com/questions/12485666/python-deleting-all-files-in-a-folder-older-than-x-days>
In IDLE, go to Options → Configure IDLE → Keys and there select history-next and then history-previous to change the keys.
Then click on Get New Keys for Selection and you are ready to choose whatever key combination you want.
From <https://stackoverflow.com/questions/4289937/how-to-repeat-last-command-in-python-interpreter-shell>
2018-09-04
CSV Toolkit Overview
NOTE: THIS PROJECT HAS SINCE BEEN FORKED TO THE INTERNAL PROMETHEUS RESEACH, LLC TOOL PROPS.CSVTOOLKIT
CSV Toolkit is a Python package that provides validation tooling and processing of CSV files. The validation tooling is based on the fantastic package Vladiate. The interface and extension mechanisms are similarly implemented as the rex.core extension mechanisms.
From <https://pypi.org/project/csv.toolkit/>
What is Bonobo?
Bonobo is a lightweight Extract-Transform-Load (ETL) framework for Python 3.5+.
It provides tools for building data transformation pipelines, using plain python primitives, and executing them in parallel.
Bonobo is the swiss army knife for everyday's data.
From <https://www.bonobo-project.org/>
csvkit is a suite of command-line tools for converting to and working with CSV, the king of tabular file formats.
From <https://csvkit.readthedocs.io/en/1.0.3/>
Awesome Python
A curated list of awesome Python frameworks, libraries, software and resources.
Inspired by awesome-php.
• Awesome Python
○ Admin Panels
○ Algorithms and Design Patterns
○ Anti-spam
○ Asset Management
○ Audio
○ Authentication
○ Build Tools
○ AND MANY MORE
From <https://github.com/vinta/awesome-python>
2018-09-04
Python data visualization: Comparing 7 tools
The Python scientific stack is fairly mature, and there are libraries for a variety of use cases, including machine learning, and data analysis. Data visualization is an important part of being able to explore data and communicate results, but has lagged a bit behind other tools such as R in the past.
From <https://www.dataquest.io/blog/python-data-visualization-libraries/>
2018-09-04
Best way to sort txt file using csv tools in python
From <https://stackoverflow.com/questions/45221637/best-way-to-sort-txt-file-using-csv-tools-in-python>
import csv
import operator
#==========Search by ID number. Return Just the Name Fields for the Student
with open(“studentinfo.txt”,“r”) as f:
studentfileReader=csv.reader(f)
id=input("Enter Id:")
for row in studentfileReader:
for field in row:
if field==id:
currentindex=row.index(id)
print(row[currentindex+1]+" "+row[currentindex+2])
#=========Sort by Last Name
with open(“studentinfo.txt”,“r”) as f:
studentfileReader=csv.reader(f)
sortedlist=sorted(f,key=operator.itemgetter(0),reverse=True)
print(sortedlist)
From <https://stackoverflow.com/questions/45221637/best-way-to-sort-txt-file-using-csv-tools-in-python>
2018-08-10
The sys.path list contains the list of directories which will be searched for modules at runtime:
python -v
['', '/usr/local/lib/python25.zip', '/usr/local/lib/python2.5', … ]
From <https://stackoverflow.com/questions/269795/how-do-i-find-the-location-of-python-module-sources>
For speedtest - /usr/local/lib