All Questions
292
questions
3
votes
0answers
55 views
Lisp expression parser
I'm building a very simple Lisp interpreter. Similar to the the one from here. Here is what I have so far for the parsing part, that is, everything from "text is passed to the the program" ...
3
votes
2answers
732 views
0
votes
0answers
71 views
Asynchronous web scraping
This is my solution to a "vacancy test" task.
I'm not sure at all if I have correctly implemented the task, but here is my solution.
Goals of code:
Parse rows of table from a URL and ...
1
vote
1answer
208 views
Separate an email address into its username and domain name
This is my first ever Python program and I wanted to get everyone's opinions on it. The goal of the program is to separate an email address into its username and domain name.
...
3
votes
2answers
123 views
Parse sequence of characters detecting formatting categories
I am a beginner coder and SonarLint tells me code is too complex. I tried recursion, iterators, slicing but had not luck making this code any simpler.
The code will parse the input string to detect ...
10
votes
1answer
1k views
Parsing overly complex JSON
The Merriam-Webster Dictionary API at some point discontinued the use of XML in favor of exclusively returning JSON. This had the unfortunate effect of making finding a definition listed by sense ...
3
votes
2answers
126 views
Python: Parse string of bracketed list items into list of strings
I have a string containing several items listed in the following notation:
myString = '[A][B][C]'
And I would like to parse that to a python list of several ...
6
votes
1answer
392 views
Parsing a JSON one line at a time in Python
happy 2021 everyone!
I started coding some months ago for fun and recently I challenged myself to build a JSON parser in Python (v3.8).
The basic idea was to avoid loading the whole file at once, ...
2
votes
1answer
68 views
Extract values from English numerals, e.g. “nine million and one”
Though many have done it the other way around, I have not seen such code in many places. And, to be honest, I don't know why this cluster of if-statements, ...
6
votes
2answers
152 views
Separating data from string representation of objects, with added extras
Given a string representation of data, I want to extract the information into its corresponding object.
However,
If the string has "|" separators then these should be considered options and ...
3
votes
2answers
54 views
Handle missing children nodes when parsing XML into a dictionary
I work on a code-base that uses xml to set up problems and specify model parameters. I've created a script that I run in tandem with our code. This script will ...
11
votes
3answers
407 views
FASTA-to-tsv conversion script
I worked on a script that takes as input a multi-sequence .fasta file and outputs the number of each aminoacid/sequence in a .tsv...
4
votes
2answers
106 views
Counting Characters from an HTML File with Python
I just completed level 2 of The Python Challenge on pythonchallenge.com and I am in the process of learning python so please bear with me and any silly mistakes I may have made.
I am looking for some ...
10
votes
1answer
704 views
Python molar mass calculator
I created the following program which takes a molecular formula as an input, eg CH3COOH and returns the molar mass of the compound:
...
2
votes
2answers
114 views
Parse python code, for specific pep8 issues
I am aware, that libraries exist for parsing python code, however, for the sake of learning how they parse errors, I'm creating a script that checks a file for only 6 Pep8 errors just for reference.
...
3
votes
1answer
154 views
Parse selected records from empty-line separated file
This is my first post here and I hope I will get some recommendations to improve my code. I have a parser which processes the file with the following structure:
...
8
votes
1answer
220 views
Making argument parsing more streamlined and readable than if-statements
I am working on an API wrapper for calls to a website. Each of several types of calls can take a large number of optional arguments, some of which contradict. In the interest of preventing the user ...
7
votes
2answers
260 views
Simple python string to list parser
So I came across this question on SO and I felt like it would be a cool thing to try and write a parser for since I always wanted to try it. So I present to you:
My first time writing a parser.
It ...
3
votes
1answer
375 views
Parse HTML bookmarks file to JSON using python
I am currently working on a project for an online course, my goal is to create a bookmark manager web app. So I created this python script to parse a chrome/firefox HTML bookmarks file (Netscape-...
3
votes
1answer
47 views
Extracting average time series
I have this JSON code that I got from a get request with Azure API. Everything works how I want it but it doesn't look good. There must be an easier way to parse the data.
...
4
votes
1answer
159 views
Is there a better way to parse this data file?
I have a text data file in SPWLA format; I cannot find a specification for it. It contains physical measurements and/or rock descriptions from wellbore core samples. It's fairly gross. The example ...
6
votes
1answer
97 views
Tool for converting OEIS sequences into Desmos lists
https://github.com/CascadeIllusion/DesmOEIS
Recently began work on a Python project called DesmOEIS to build up my portfolio. It's a simple console program that looks up integer sequences from the ...
2
votes
2answers
65 views
Finding pupils to tutor
I am a Math tutor and I found the site https://www.yksityisopetus.fi/ where one can search pupils. I made a Python parser to find pupils that want Math teaching with at least 25 €/hour. Are there any ...
2
votes
1answer
404 views
Import huge XML data set into MongoDB while parsing data
I am currently working with the Stack Exchange Data Dump - to be more precise - with the dumped Posts.xml data set from Stack Overflow.
What am I trying to achieve?...
4
votes
1answer
74 views
A self contained parser generator implementation
This is a recreational project, I was trying to make a parser generator with a grammar inspired from: https://docs.python.org/3/reference/grammar.html
Unfortunately, understanding that specific ...
9
votes
3answers
217 views
Performance - Read large amount of XMLs and load into single csv
I am dealing with a large amount of XML files which I obtained from here https://clinicaltrials.gov/ct2/resources/download#DownloadAllData. The download yields around 300.000 XML files of similar ...
3
votes
1answer
62 views
Tar archive parser - custom implementation
I'm learning python and for educational purposes I implemented tar archive parser. I'm not beginner programmer. I would like to receive some feedback and tips about code, what can I improve, what ...
4
votes
2answers
839 views
Parsing a shop receipt
I've been working on a parser for shop receipts which extracts data about the payment. Here is the text that I'm parsing:
* Vic107Payment
Text: PINNEN
TicketData: POI: 12345678 ...
2
votes
1answer
939 views
Parsing a TLV string
This piece of code is supposed to walk through a TLV string and print out its contents. For this particular example, tag field length is 2, size field length is 3.
As a mostly C programmer, this is ...
5
votes
2answers
5k views
Python insert line in the middle of the file
I will be inserting a new text line in a setup.py file, this new line will contain text, and is part of the REQUIRED_PACKAGES. I ...
3
votes
2answers
88 views
Word bucketing in Python
First I'm not sure what this is called formally but whatever.
Basically I need to form "wildcard buckets". I think the best way to explain what I need to do is to take an example. For instance, say I ...
5
votes
2answers
298 views
Evaluating arithmetic expressions and plotting graphs
I just got started with Python. I created some code, and I want to know what more experienced devs think about it. What can I do better? What to avoid?
...
3
votes
1answer
116 views
Extracting event strings and message objects from Twitch IRC messages
I am looking for a better way to minimize nested if statements in my MessageHandler.handleMessage method. I am looking to adhere to SRP and a function should do one ...
10
votes
3answers
767 views
Recursive Descent Parser Implementation for a Recursive Language
I'm writing toy parsers for toy languages to understand how parsers work.
Assuming a language as follows (in sketchy EBNF patois)
...
7
votes
3answers
2k 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.
...
2
votes
1answer
273 views
Quadratic “Complete the Square” Solver in Python 3
I quickly wrote this program to transform quadratic expressions in general form into vertex form.
\$ax^2 + bx + c \;=\; a(x-h)^2 + k,\quad\text{where}\quad h = -\frac{b}{2a} \quad\text{and}\quad k = ...
12
votes
4answers
1k views
6
votes
2answers
291 views
Tokenizing SGML text for NLTK analysis
I have an NLTK parsing function that I am using to parse a ~2GB text file of a TREC dataset. The goal for this dataset is tokenize the entire collection, perform some calculations (such as calculating ...
7
votes
1answer
239 views
Interpret a date from a string of digits
I developed a function that, from a given sequence of digits, extracts the date and reformat it.
This is the code:
...
0
votes
1answer
77 views
Aggregating recent trading data from Bitcoin derivatives exchange
As a component of some trading software, I wrote function parse_ticks(), as part of an Exchange class that models the Bitcoin ...
7
votes
4answers
155 views
Parser for a log file
I wrote a parser to extract data from a log file. The file format is a bit irregular, and so is also the parser code, as it turned out. It is a clutter of different loop types, different ways to ...
3
votes
1answer
235 views
Parsing large text files - Masking all bank numbers
I had a friend ask me to write this up for her as she discovered her logs were saving private bank information in plain text. This is used to parse a few hundred gigs of text files. I've never worked ...
8
votes
1answer
67 views
Break text into letters (regular Unicode graphemes+language specific digraphs)
In English, "Sh" is two letters. In other languages it's considered a single letter. I'm trying to calculate the length of a string in a Unicode aware way, with this in mind. I'm imagining a function ...
3
votes
1answer
613 views
Nested for-loops in xml parsing
I wrote program that reads and processes xml files submitted by external users. The part of the code in question iterates over xml node's children, appends a dictionary - a future row in a table, and ...
4
votes
3answers
389 views
Python process tracklist, get cumulative timestamp of each track
The code below parses a tracklist (sample input below) and generates a six-member tuple, including cumulative timestamps in mm:ss. (sample output at bottom).
...
3
votes
2answers
96 views
script to check sequence number in a binary file
This is a script to check the sequence number (8 bit unsigned integer) in a binary file and make sure it is incrementing till the end and not missing any sequence number in between. Sequence number is ...
4
votes
1answer
74 views
Tab 2 spaces convertor (for markdown)
This program converts glob files' tabs to spaces.
There is a special case to ignore content inside triple back ticks.
Example usage is ./tab_2_spaces.py *.md
Main ...
4
votes
1answer
127 views
Footwear scraper
I've done this parser to scrape all footwear data, but I don't know if it is good to use OOP in this case. Can you please check this out and give me the strongest feedback? I'm working on improving my ...
2
votes
1answer
174 views
JSON Parser, pulls data from a JSON file for analysis
This is the first time I have programmed something that I will actually personally use, so I am happy about that. I tried to write good code whilst applying functional programming concepts. So no ...
2
votes
2answers
1k views
Parse date format in Pandas using Python
I have a column in a Pandas Dataframe containing birth dates in object/string format:
0 16MAR39
1 21JAN56
2 18NOV51
3 05MAR64
4 05JUN48
I want to ...