All Questions
26
questions
15
votes
2
answers
6k
views
Evaluating arithmetic expressions
I have written some simple code for evaluating expressions. However, I am not sure how well I am following conventions (this is my first time trying to).
Specs for problem:
All binary operators (+, -...
10
votes
1
answer
415
views
Python - basis of a parser library
This is a followup of sorts to this question: link. 'Of sorts' because, as pointed out in the comments, this question should have been asked first.
I'm writing a parser library in Python, mostly for ...
9
votes
1
answer
10k
views
Creating truth table from a logical statement
This code creates a truth table from a statement in logic. The statement is input as a string, and it is identified as a tautology if it is true for all true and false combinations of the variables.
...
9
votes
1
answer
6k
views
Equation parser and solver
I wrote this equation parser and solver, I feel like it is well documented and tested:
...
5
votes
1
answer
456
views
Python parser for attributes in a HAML template
I'm working on a feature for the HamlPy (Haml for Django) project:
About Haml
For those who don't know, Haml is an indentation-based markup language which compiles to HTML:
...
8
votes
3
answers
2k
views
Calculator using tokens of numbers and operators
Lately there has been some questions regarding calculators, where the response typically has suggested simplifying the logic and using either abstract syntax tree or token lists (like I did myself in ...
8
votes
2
answers
2k
views
Parsing Wikipedia table with Python
I am new to Python and recently started exploring web crawling. The code below parses the S&P 500 List Wikipedia page and writes the data of a specific table into a database.
While this script is ...
8
votes
2
answers
274
views
Splitting plain text dictionary data to multiple files
I have a plain text file with the content of a dictionary (Webster's Unabridged Dictionary) in this format:
...
8
votes
3
answers
2k
views
Parsing oscilloscope binary data
I wrote a simply parser for Tektronix's internal binary file format .isf. The code is supposed to read in the file and return the header data as well as the actual ...
7
votes
3
answers
3k
views
Parsing molecular formula
Is it possible to improve this code in terms of efficiency / line number ? (avoid nested code ...). It comes from a test I failed. I don't know how I could have done it better.
...
7
votes
1
answer
146
views
Splitting plain text dictionary data to multiple files, round 2
This is a continuation of my earlier question.
I have a plain text file with the content of a dictionary (Webster's Unabridged Dictionary) in this format:
...
6
votes
2
answers
4k
views
Extract the title from a webpage using the python 3 standard lib
The aim of this module is to extract the title from possibly broken hypertext. Without using any awesome third party modules like bs4 or ...
6
votes
2
answers
2k
views
Calculate food company sales for the year
I am working on a Python project where a food processing company is trying to calculate its total sales for the year. Python has to read from a text file where its divided into for categories split by ...
5
votes
2
answers
118
views
Matching maximal nodes with velocities
I have written a code which works very good for small data-files (see below). The data file 'WSPL.dat' which I want to evaluate has a size of 2.6 GB and the data file 'VELOC.dat' has a size of 4.3 GB....
5
votes
1
answer
3k
views
Python Hex Viewer
I have created an hex viewer in python, as a timed-challenge by friend. My implementation was in the form of a class, with a separate main file running with argparse...
5
votes
1
answer
10k
views
Parse a config-file and add to command-line-arguments using argparse in Python
I am trying to parse the command line arguments using argparse, and if the user specifies a yaml file for the config-file, add those arguments to the args from argparse
...
4
votes
0
answers
181
views
Python - lookahead driver for a parsing chain
This is retroactive followup (that is, logically this is a followup, chronologically it isn't) to this question: link.
I'm writing a parser combinator library in Python. An important thing that must ...
3
votes
1
answer
389
views
Parsing Solr log files - version 2
This post is in reference to: Parsing Solr log files
I re-wrote most of the code and split it up into a couple of classes. Currently, the class functionality is pretty limited, but I can see that I ...
3
votes
0
answers
73
views
Advent of Code 2021: day 10- Syntax Scoring
The following code solves day 10 in the advent of code challenge.
The goal for this time around is evaluating whether a line of brackets
is complete, has a syntax error or is missing some closing ...
3
votes
2
answers
280
views
RSS to HTML script - version two
I wrote this script that downloads an RSS feed and converts it to HTML. One of my only concerns is my variable naming because I suck at naming things.
...
2
votes
1
answer
3k
views
Parsing video files from a given directory
I have written a little class that is basicly looking for video files in given directory and then parsing some info about those files. Finally it saves everything in a list.
To properly run this you ...
2
votes
1
answer
635
views
Parsing Solr log files
I am kind of new to programming. Picked up some Perl about a year ago and now learning some Python. I am pretty confident in Perl, but Python seems un-natural to me.
I wrote a little script that ...
2
votes
1
answer
417
views
Parsing oscilloscope data, follow up
Follow-up up on Parsing oscilloscope binary data.
I wrote a simple parser for Tektronix's internal file format .isf.
I revised my code to the following:
...
1
vote
1
answer
103
views
using pandas and numpy to parse dirty .csv
I'm relatively new to Python have been writing for a few months now. I've started a Pandas Numpy project that starts with parsing large and somewhat sloppy formatted textfile, its not exactly csv but ...
1
vote
1
answer
2k
views
Parsing JSON in one go using state machine solution
I need to parse a simple JSON string (flat JSON, no hierarchy) for keys and values, and there is a system constraint that I cannot use any built-in JSON library and can only read a string once due to ...
1
vote
1
answer
135
views
Partial implementation of parsing a config-file and command line options
I need to be able to accept some options from either the command-line or a config-file.
This code is a snippet of the class that I am working on, I cannot post the entire class here. This code works, ...