Skip to main content

A collection of methods to read and organize data stored in text

Project description

Text Parsing Tools

This is a collection of various functions to aid in parsing and organization of data stored in text files.

Installation

You can install Text Parsing Tools from a command line via PyPI:

python3 -m pip install textparsingtools

This library was programmed using Python 3.8, and it has not been tested on older versions.

How to use

Import the library and use its functions as needed. Here is a quick demo:

import text_parsing_tools

file_path = '<insert path here>'
input_file_name = 'Input file'
output_name = 'Output spreadsheet'

replacement_strings = [[' - ', '-'], ['   ', '  ']]

with open(file_path + input_file_name + '.txt', 'r') as input_file:
    file_lines = [recursively_replace(line , replacement_strings) for line in input_file.readlines()]

data_1 = get_text_data(file_lines, r"data_begin", r"data_end", 0, 1, data_begin_offset = 4)
data_2 = get_text_data(file_lines, r"data_2_begin", r"data_2_end", 0, 1, 2, 3, data_begin_offset = 5)

unique_names = []
[unique_names.append(row[0]) for row in data_1 if row[0] and row[0] not in unique_names]
[unique_names.append(row[0]) for row in data_2 if row[0] and row[0] not in unique_names]

data_1 = transpose_transcript_data(data_1, unique_names, empty_value = '=NA()')
data_2 = transpose_transcript_data(data_2, unique_names, empty_value = '=NA()')

combined_data = interleave_datasets(unique_names, data_1, data_2)

variables = ['Var 1', 'Var 2', 'Var 3', 'Var 4']
header = build_header(unique_names, variables)
write_excel_file(file_path + output_name, [combined_data], header)

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

textparsingtools-1.1.6.tar.gz (17.5 kB view details)

Uploaded Source

Built Distribution

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

textparsingtools-1.1.6-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file textparsingtools-1.1.6.tar.gz.

File metadata

  • Download URL: textparsingtools-1.1.6.tar.gz
  • Upload date:
  • Size: 17.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

File hashes

Hashes for textparsingtools-1.1.6.tar.gz
Algorithm Hash digest
SHA256 8ebdb29d2df54b6968290783817f7bfac13c132e0557050361297a59efd1c87c
MD5 b291fa7d4bcce15b3c12a39d1418bccc
BLAKE2b-256 df180597ba44b9277dfd4ded9d092c17916c59555929443a38df7b7bc49ff986

See more details on using hashes here.

File details

Details for the file textparsingtools-1.1.6-py3-none-any.whl.

File metadata

  • Download URL: textparsingtools-1.1.6-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

File hashes

Hashes for textparsingtools-1.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 cb14c0a24e65c70e9d436ae3cf5560bc1c4574bf500acd39b0ee21bc4a2ae974
MD5 a6791d6c3a9f579542a7b858a9c29c7f
BLAKE2b-256 c4c87cb864abceb53889542f003a4782f56b85b061800bb7606ac279ab0a36db

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