Smarter Faster way from CSV to dict.
Project description
best_csv
This library converts a csv file to a Python dictionary. "So what!?!?" you may ask :). This library does it better, more efficienty and greatly improves your querry times over the built in csv Python library. The built in csv Python library has a lookup complexity of O(n) where runtime grows directly in proportion to n; best_csv has a lookup complexity of O(1) which means that it takes a constant time to lookup regardless of the dataset size.
Now, this library might not be ideal for all csv datasets but is great for datasets that have a column that we can use as a unique identifier for any given row of information. For example, if we have a dataset of employees and each row is an employee record we can use the employee IDs as the key for any given employee in the dictionary.
The standard Python csv library will create a list of dicts so if you want to search for specific employee IDs you have to potentialy loop though all of the dataset to find the employee you want; whereas with best_csv you simply call the employee ID you need without having to loop through the dataset. This is great if you have massive datasets and you are running multiple querries.
Installation
Use the package manager pip to install dnac_device_list.
pip install best_csv
Usage/Examples
import best_csv
# Headers in employee_data.csv
# User Id,First Name,Last Name,Email,Phone,Date of birth,Job Title
# Convert your csv to dict with column 1 as the unique key for any given row.
result = best_csv.csv_to_dict("employee_data.csv", 1)
print(result['AB123']) # Print info of Employee ID AB123
result['AB123'] print simulation
{'First Name': 'Wesley', 'Last Name': 'Chung', 'Email': 'wcab123s@acme.org', 'Phone': '(280)277-4903', 'Date of birth': '1953-04-21', 'Job Title': 'Security Engineer'}
Authors
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file best_csv-1.2.tar.gz
.
File metadata
- Download URL: best_csv-1.2.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5900f958a535d2876d5121fb2a261bb1b5ba200a6712b3241be5602c0984703f |
|
MD5 | f03a153f8d4e469fcaf56f614aa028d7 |
|
BLAKE2b-256 | 103f5797776d1d29b4392ed3de45260fa112465ab367ec2e300d3c2fce6ad9c8 |
File details
Details for the file best_csv-1.2-py3-none-any.whl
.
File metadata
- Download URL: best_csv-1.2-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c92352b586addb1cc18ae77e3978fbf8d7795cba9db42c1e478b37c76db8141a |
|
MD5 | 0304893761214eb67f59815de669d3fe |
|
BLAKE2b-256 | 6b5cf9131b28697115ff9a417ed69520aa941d049b33db536bab680e213469b5 |