Giter VIP home page Giter VIP logo

Comments (11)

dmaziuk avatar dmaziuk commented on September 9, 2024

If you're just reading a file looking for specific tag, SAS has a separate parser for this: one that returns tag-value pairs.

I think if you wanted to Do It Right(tm) you'd add a Row class to the loop -- like sqlite3 does it: optional via row_factory. Jon?

from pynmrstar.

varioustoxins avatar varioustoxins commented on September 9, 2024

? If you're just reading a file looking for specific tag, SAS has a separate parser for this ? - not quite sure I follow the sas reference

from pynmrstar.

jonwedell avatar jonwedell commented on September 9, 2024

Here is something which exists already and I believe meets your needs:

>>> a = pynmrstar.Entry.from_database(15000)
>>> l = a[0][0]
>>> l.get_tag(['ordinal', 'family_name'], dict_result=True)
[{'Ordinal': '1', 'Family_name': 'Cornilescu'}, {'Ordinal': '2', 'Family_name': 'Cornilescu'}, {'Ordinal': '3', 'Family_name': 'Hadley'}, {'Ordinal': '4', 'Family_name': 'Gellman'}, {'Ordinal': '5', 'Family_name': 'Markley'}]

The only difference being that you need to specify which tags you want. The presumption here is that you don't need the dictionary to contain values your code doesn't know how to handle - since presumably they would just be ignored anyway. It also would raise an exception if you ask for a tag that isn't present, which would make it clear where an issue is right away, versus getting a generator of values and only realizing later that a particular key is missing with an IndexError.

If you really do need all the tags in the dictionary though, you could do the following:

l.get_tag(l.tags, dict_result=True)

Though that is admittedly a little clunky looking, it will work fine.

from pynmrstar.

dmaziuk avatar dmaziuk commented on September 9, 2024

? If you're just reading a file looking for specific tag, SAS has a separate parser for this ? - not quite sure I follow the sas reference

https://github.com/bmrb-io/SAS -- there is a python3 branch that passes basic tests.

from pynmrstar.

jonwedell avatar jonwedell commented on September 9, 2024

Here is something which exists already and I believe meets your needs:

Though looking at this further, it really should return the tag names with the same capitalization you use to query them. Otherwise if your specified capitalization doesn't match the file, you'll run into an annoying discrepancy. I'll look into updating this code.

Does this meet your needs? If not, if you describe exactly what sort of operation you're performing on the loop as you iterate through the rows, I may be able to provide an idiomatic way to do it.

from pynmrstar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.