Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python Challenge #3

Open
ryan-duve opened this issue Mar 23, 2023 · 2 comments
Open

Python Challenge #3

ryan-duve opened this issue Mar 23, 2023 · 2 comments

Comments

@ryan-duve
Copy link

I would like to submit a solution for the challenge on the bottom of this page:

If you think that this could be done significaanly easier in python than the python solution above, here is a link to a smaller file on which you can try your code. I will be glad to share the solution on this page.

data = {"Frequencies":[], "Frc consts":[], "IR Inten":[]}

with open("H2O.log") as f:
    for line in f.readlines():
        for label in data:
            if label in line:
                data[label].extend(line.split()[-3:])

for line in zip(*data.values()):
    print(" ".join(line))

I hope it is a useful comparison to the awk script. Please let me know if you'd like any explanation on how it works.

@pmitev
Copy link
Owner

pmitev commented Mar 24, 2023

Neat!
If you allow me, I will add it in the page as the other contributions.

@ryan-duve
Copy link
Author

@pmitev -- Sounds good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants