Skip to main content

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


Download files

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

Source Distribution

best_csv-1.2.tar.gz (3.4 kB view hashes)

Uploaded Source

Built Distribution

best_csv-1.2-py3-none-any.whl (3.8 kB view hashes)

Uploaded Python 3

Supported by

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