Questions tagged [parsing]

Parsing is the process of analysing a string of symbols, either in natural language or in computer languages, conforming to the rules of a formal grammar.

Filter by
Sorted by
Tagged with
6
votes
1answer
683 views

SHA1 hash of every file in a directory tree

I have a few important files that I would like to preserve, so I make multiple backups of them. In order to check their integrity, I decided to write a python script that would help me with this task. ...
3
votes
1answer
93 views

Scraping metrics from log files

https://github.com/bodgix/log2metric/pull/1 This is my very first Go program so please forgive any beginner errors. This is a rewrite of a monitoring script I had written in Ruby. Coming from Ruby, ...
3
votes
2answers
70 views

Format python data structures in HTML no dependencies

My poorly written tests suggests that the module works as intended. I fear this is to good to be true. I don't known how to write unit tests for this. I'm new to writing tests and I think this module ...
14
votes
2answers
756 views

Parsing Z80 assembler in C++

I'm just starting with C++ (I have worked with C for more than a year) and as a first program I wanted to write a cleaner version of my Z80 assembler I had written in C before, this time trying to do ...
13
votes
1answer
31k views

Parse complex text files using Python

I'm looking for a simple way of parsing complex text files into a pandas DataFrame. Below is a sample file, what I want the result to look like after parsing, and my current method. Is there any way ...
11
votes
4answers
1k views

Parsing RFC 4180 CSV with GOTOs

One of my data-import tools needs to support CSV files. I thought that parsing CSV is such a simple task that I didn't want to use any any external libraries for that. So here is one more RFC 4180 CSV ...
2
votes
0answers
312 views

nom Parser in Rust

I'm attempting to make a parser using nom in Rust. Nom implements parser combinators, so more complex parsers are built from simpler parsers. Because of this, I've started with a simple ID token ...
1
vote
1answer
29 views

Scan a list of assigns in nodejs

My starting point is a file like so: ...
6
votes
2answers
2k 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 ...
4
votes
0answers
114 views

File operations using Groovy

The idea is to read a file - "data" - and write the information to a new file - "output" - only if it meets the criteria (if the resource usage is more than a configured threshold). Content of the ...
2
votes
1answer
197 views

Simple state machine based command-line argument parser

I'm in the process of learning to write idiomatic JavaScript code so naturally I'm parsing command line arguments. My approach to this is to have a simple state machine. The parser should work as ...
3
votes
1answer
864 views

HTML parser written with the Python 3 standard lib

I'm working on a project where I have to extract some basic information from webpages like links, title etc. I can't use any of the awesome libs like bs4 or my ...
2
votes
1answer
5k views

MIPS assembly string to int function

I have written the following code for a programming assignment. I would appreciate some help to improve this code and see if it meets all the requirements and criteria. I would like to improve my loop ...
6
votes
1answer
362 views

Simple python code takes command line argument for file location and tokenizes text

The usage of this Python program is: python ~/test.py test.txt Here is the source: ...
3
votes
2answers
212 views

Parse atom RSS feed with xml.dom.minidom

I had to parse a blogger RSS feed but I didn't have access to any third party modules like feedparser or lxml. I was stuck with the task of writing a library to parse RSS feeds; challenge accepted. I ...
6
votes
2answers
420 views

Complex parser in C#

Last time I asked for a review of my tokenizer, and I would like to thank for all of the feedback! This time I wrote a parser for my language. The parser generates an AST (abstract syntax tree), from ...
2
votes
1answer
738 views

Parse heterogenous JSON array

I need to parse a JSON generated by iTunes Search API. I'm looking for all apps by a certain developer, and I usually get a response like this (simplified): ...
1
vote
0answers
535 views

Building a data tree out of a text file C#

Need some help and suggestions how to create a data tree from a text file. I'll try to explain as better as I can the setup I intend to use and currently have. Game classes in my game are populated ...
1
vote
0answers
404 views

Infix to RPN converter using the Shunting-Yard Algorithm

I need to be able to parse simple equations in an app I'm writing, and decided to try writing my own parser. I ended up using the Shunting-Yard Algorithm to convert from infix notation to RPN as the ...
1
vote
0answers
65 views

Brain-flak interpreter

I'm learning Go, so I decided to make a Brain-flak interpreter for practice. ...
3
votes
0answers
194 views

Converting English words to numbers in Haskell

A few weeks ago, I finished a number to word converter and received an excellent review. It caused me to make several fundamental changes to numToWord, such as ...
2
votes
0answers
27 views

Parsing diff-like annotations

I am working with annotated text that has data describing changes on it. Changes are represented by lines consisting of groups of "+++" and "---", each referring to the characters in line above. ...
4
votes
1answer
68 views

a Python2 to Python3 print fixer in perl

Sometimes, I'm reviewing old questions written in Python2, with no parenthesis around print statements. Or I'm changing one of my older codes, also without ...
4
votes
1answer
153 views

Converting anki-furigana to HTML-furigana without parser libraries

I wrote a converter from anki-style furigana to HTML-style furigana. Eventually I want to do it as a parser, but as a first step I do it without. Furigana is used to write the pronunciation over ...
1
vote
1answer
41 views

Parsing fixed-width format with J

I have a fixed-width input format. The widths are known to me. Suppose I am told that the first field is 20 characters, the second is 10, the third is 12. The total width of a row should therefore be ...
2
votes
2answers
110 views

Parse output of Google Cloud command into PHP associative array

This is my idea on how to turn Shell exec output in PHP to array output. I just want to share it and get feedback in case there is any better way. Below is a code example to get server info from GCE. ...
9
votes
3answers
11k views

Simple JSON parser in C

Here is a simple recursive descent JSON parser, not a lot of extra functionality, although it does use the expandable vector class reviewed here (Simple expandable vector in C). I did not implement ...
3
votes
2answers
837 views

DFA creation from string

I have fairly simple Python 3 code that creates a DFA from a string. It works great, but I believe it can be made more efficient. There are a total of 3 loops: First iterates over the string Second ...
5
votes
1answer
65 views

Class to parse a file sanitizing each line with a set of methods

I am parsing a set of lines from a file, after reading the file content with Parser.read_file() I apply a set of methods to solve different issues each line may ...
2
votes
4answers
120 views

Taking 2 command line inputs and verifying that they are integers, within the correct range of values

I'm taking 2 command line inputs, which have to be integers between 2 and 1,000,000. These two values are then passed into the getPrimes function, which is just a ...
2
votes
3answers
553 views

Shell script to parse variable definitions from Scala build file

The build.sbt text file contains versions like this: name := "happy" scalaVersion := "2.11.8" sparkVersion := "2.2.0" I wrote ...
4
votes
3answers
447 views

Using PHP explode() to parse multi-part error messages

I am dealing with a system which sends any unexpected errors back to me in a string, for example: ...
4
votes
2answers
1k views

Compare two CSV files In Ruby

I wrote my first program in Ruby that compares two CSV files, but I'm sure there are more efficient ways to do it. I tried using the Ruby CSV library at first, but it was unproductive. Please let me ...
18
votes
4answers
10k views

Simple lexer in C++

I haven't written anything in C++ in a couple of years, so I have both forgotten a lot and also wasn't exposed to the modern C++. I am working on a toy programming language and while other parts are ...
4
votes
1answer
563 views

Scanner/Lexer in Java

I wrote a scanner/lexer to parse my language. Some notes: I'm scanning files written in UTF-8. I avoided regex for two reasons: It feels far easier to simply handle codepoints one at a time than ...
5
votes
2answers
189 views

Alternative to nonlocal for local variables in a function with nested functions in Python

Introduction for future readers I posted the code below in the hope that it would be a good example to discuss the topic "Alternative to nonlocal for local variables in a function with nested ...
7
votes
1answer
2k views

Tokenizing a file with a generator

I'm parsing (specifically tokenizing) a file, line-by-line. I've a method tokenize, that takes a string (one line of code, it can't take the whole file at once), breaks it into parts, and returns a ...
6
votes
1answer
814 views

SQL lexer in JavaScript

Context Some time ago I wrote a very simple SQL interpreter for Javascript for fun one weekend and have since started using it in production in a few projects for work, and as requirements change for ...
6
votes
1answer
66 views

Laser cutter daily reports parser

In my Python journey I was looking for a "real life" problem and I think I have found a good one at my current work. The laser CNC machine I'm working with generates reports that contains timings of ...
2
votes
0answers
156 views

Compiles SCSS Code to CSS in the browser

First of all, thanks for reviewing my code. I am half-way done through a GitHub Project I call ScriptSass, that parses SCSS Code using Javascript into regular CSS. Now, I have reluctantly added an ...
2
votes
1answer
427 views

Lotus Domino API - Parsing through NotesItems

I have an application that opens a bunch of .nsf databases (73 for now, and that might increase in the future), reads the documents, and reads the items of these documents. Based on the item name, I ...
1
vote
0answers
133 views

Converting Cisco IOS output to XML

The INPUT FILE is created by a script that runs "show interface description | i FN" against each of my routers. Once I have that file, my PYTHON SCRIPT below, parses the INPUT FILE for each of the ...
1
vote
0answers
123 views

Golang Opengl OBJ Loader

I'm trying to get better in go by make a 3D game. (Yes, I know that's a lot of work but I'm doing it for experience and not to make a profit.) And I want to improve the loading of the OBJ Files as ...
4
votes
3answers
420 views

Parse a stream of space separated numbers

I need to parse a stream of characters IEnumerable<char> as a list of space (and newline) separated numbers. Numbers can be expressed in base 10, base 8 (...
3
votes
2answers
2k views

Parsing command line arguments in Go

I've written a reimplementation of the redis-benchmark in Go and part of that is parsing options from the command line. I evaluated several libraries but nothing I found seem to do what I had in mind. ...
1
vote
0answers
194 views

PHP - Uri Parser for Routing

I'm trying to build my own PHP MVC framework. I want to implement a routing similar to how ExpressJS/NodeJS implements its routing by making use of Request Handlers. ...
6
votes
1answer
5k views

Read a .ini file

I got frustrated with C++ not being Python, so I put together a .ini file reader for myself. The last C++ code I posted, the feedback was that it's better to use free functions that private static ...
4
votes
1answer
3k views

Parsing indented text and inserting its data into a tree

My goal is to parse indented text in the style of python and YAML. This only find the parent of each line. This bit of code seems to do the trick, but I'm not really satisfied and I wanted to know ...
2
votes
2answers
627 views

Parse a formatted string, which may have duplicate keys, into a map

I have a String which is coming in particular format so I want to parse that string into map. I have a below method which parses String to a Map and it works fine. ...
1
vote
1answer
69 views

Mail merge (Parsec string formatting) example

My intent is to perform "mail merge" where I can write strings like "hi <<name>>" and format them according to a ...