Skip to main content

Bulk Data Python Package makes it easy to create and manipulate bulk data files.

Project description

Bulk Data Python Package

https://img.shields.io/pypi/v/bulkdata.svg https://img.shields.io/travis/marcodlk/bulkdata.svg Documentation Status Updates

Bulk Data Python Package makes it easy to create and manipulate bulk data files.

Features

  • Card objects represent Bulk Data Cards; functionally similar to list objects but can be serialized to a bulk data formatted string representing the card.

  • No explicit Bulk Data Card definitions are necessary.

  • Deck objects represent a Bulk Data “Deck” containing Bulk Data Cards that can be added, edited, or deleted.

  • Loading BDF files containing mixed formatting is supported.

  • Bulk Data Formats currently supported:
    • Fixed (same as Small in NASTRAN)

    • Free

Example

This a quick example of using the bulkdata package to update a BDF file.

from bulkdata import Deck, Card

bdf_filename = BDF_DIR + "/example.bdf"

# load Deck from BDF file
with open(bdf_filename) as bdf_file:
    deck = Deck.load(bdf_file)

# CORD2R variables
cid = 1
rid = None
a = [-2.9, 1.0, 0.0]
b = [3.6, 0.0, 1.0]
c = [5.2, 1.0, -2.9]

# create CORD2R card
cord2r = Card("CORD2R")
cord2r.append(cid)
cord2r.append(rid)
cord2r.extend(a)
cord2r.extend(b)
cord2r.extend(c)

# print the CORD2R card in fixed format (the default)
print("-- CORD2R fixed formatting --")
print(cord2r.dumps("fixed"))

# print the CORD2R card in free format
print("-- CORD2R free formatting --")
print(cord2r.dumps("free"))

# add card to the deck
deck.append(cord2r)

# get AEROZ card
aeroz = deck.find_one({"name": "AEROZ"})

print("-- AEROZ before update --")
print(aeroz.dumps())

# update the ACSID field (first one)
aeroz[0] = cid

# update mass and length units fields while we're at it
aeroz[[3, 4]] = ["N", "M"]

print("-- AEROZ after update --")
print(aeroz.dumps())

# dump Deck to update BDF file
with open(bdf_filename, "w") as f:
    deck.dump(f)

Output:

-- CORD2R fixed formatting --
CORD2R  1               -2.9    1.      0.      3.6     0.      1.      +0
+0      5.2     1.      -2.9

-- CORD2R free formatting --
CORD2R,1, ,-2.9,1.,0.,3.6,0.,1.,+0
+0,5.2,1.,-2.9

-- AEROZ before update --
AEROZ           YES     NO      SLIN    IN      400.    300     12000.  +0
+0      10.     0.      0.

-- AEROZ after update --
AEROZ   1       YES     NO      N       M       400.    300     12000.  +0
+0      10.     0.      0.

For a more detailed overview check out the documentation and/or the bulkdata-usage notebook.

TODO

  • Add support for BDF files containing INCLUDE statements.

  • Add support for Large Field entries

  • Add support for BDF files with tabs?

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

History

0.4.0 (2020-04-10)

  • First release.

0.5.3 (2020-04-14)

  • Fixes some bugs in the Card class.

  • Expanded documentation on:
    • usage

    • API
      • Card class

      • Deck class

0.6.0 (2020-04-23)

  • Sorting deck cards is now possible with Deck.sort method.

  • Dumping cards containing trailing blank fields no longer creates blank continuation lines, as trailing blank fields are ignored when converting card to string.

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

bulkdata-0.6.1.tar.gz (51.7 kB view details)

Uploaded Source

Built Distribution

bulkdata-0.6.1-py2.py3-none-any.whl (22.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file bulkdata-0.6.1.tar.gz.

File metadata

  • Download URL: bulkdata-0.6.1.tar.gz
  • Upload date:
  • Size: 51.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5

File hashes

Hashes for bulkdata-0.6.1.tar.gz
Algorithm Hash digest
SHA256 c9003592474e409ab69099734e8ccbb83d19f05bce043d9cd77d4990e00de7ca
MD5 65411d88a8035b1a3dccb08995530a0e
BLAKE2b-256 20ec7448821478224cce48c60a2e2fe3377a2f35bf3c5805a2b5ac321e5339b4

See more details on using hashes here.

File details

Details for the file bulkdata-0.6.1-py2.py3-none-any.whl.

File metadata

  • Download URL: bulkdata-0.6.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 22.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5

File hashes

Hashes for bulkdata-0.6.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ab967770d81e459898e0a775e7dc425b5c38898bc9b02b0c06753da8b353037b
MD5 daf302bf883fa8398701c732c796ae93
BLAKE2b-256 d7f1ec9e0288210fbd8c1fd026c17cd15c0ff95738290a0619c2af47917e6400

See more details on using hashes here.

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