Comments (11)
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.
? 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.
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.
? 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.
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)
- Files without categories read ok HOT 2
- loop with no data warnings HOT 3
- A typo in error message HOT 2
- pynmrstar library should not use logging.basicConfig HOT 3
- odd behaviour of frame_codes HOT 2
- pynmrstar should use its own logger?! HOT 4
- get Loop tags without category HOT 5
- should PyNMRSTAR describe itself as a star file parser HOT 7
- running the tests fails with missing file naughty-strings/blns.json HOT 1
- tests fail with missing file /naughty-strings/blns.json HOT 3
- Is uniform indenting possible HOT 5
- changing the category of a frame corrupts the sf_category tag HOT 2
- Show a better error message when a user attempts to render a file with an empty string
- Data loss occurred while output if proper key tag was missing HOT 2
- Release 3? HOT 4
- When validating an entry, ensure that saveframe pointers point to saveframes of the correct category HOT 2
- If loading an entry fails with a 403, implement an exponential back off and retry rather than throwing an IOError
- Change write_to_file() defaults to preserve empty tags and loops HOT 1
- Problem frame without tags won't print loop HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pynmrstar.