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
4
votes
1answer
47 views

How can this C++ json library be improved

I need a class to generate json content from data retrieved from a database. This gave me an excuse to play at creating a json library. This is my first attempt so it could probably be improved in ...
2
votes
0answers
30 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 ...
8
votes
3answers
158 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
55 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 ...
0
votes
1answer
46 views

bad GNU libc argp code [closed]

In helpcovid git commit e27dd3b123c18300665 we have a stupid bug related to Linux GNU glibc argp program argument parsing. <...
2
votes
1answer
34 views

Reading bytes between two quotes from a stream and decoding it to its appropriate character set [closed]

This is a component for a lexer which operates on a byte input stream that handles reading and decoding the contents of a string contained within double-quotes. The validity of the encoding is handled ...
0
votes
1answer
37 views

Read XML file and output team lineups [closed]

I have to use Methods or Functions so my code is "better". I have no clue wich Methods or Function to use or how that exactly works since i am pretty new to NodeJs. I also had a lot of help with my ...
3
votes
2answers
738 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
113 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
223 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
57 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
209 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? ...
2
votes
0answers
54 views

Parsing a Graph To Convert It Into Adjacency Lists And CSR And Then Make Connection Queries Using Bidirectional BFS

I was assigned an university project where I had to parse directed graph files coming from SNAP and then convert them into CSR (Compressed Sparse Row) format. Then the client must have the ability to ...
4
votes
2answers
128 views

INI config loader / saver

Please take a review of my simple .ini config loader / saver: ...
4
votes
1answer
84 views

Lexer written in Rust

So I ported a lexer I wrote in C++ over to rust, as I'm starting to learn rust. Since I'm very new though, I don't know any Idioms and good practices in rust. So if anyone could point out some (...
1
vote
1answer
72 views

Color highlighter / annotator in Haskell

I'm a Haskell beginner, and I wanted to make a color annotator or color highlighter, one which takes a text as standard input, and outputs that text, with its color words highlighted using the colors ...
2
votes
1answer
26 views

Parse Wavefront OBJ using ReadP

I've been reading Haskell tutorials and books for a while, but I never actually did serious stuff with it. This is my first attempt. It parses an OBJ-file in text format. Later on I will add some ...
0
votes
1answer
58 views

JSON-Parser written in Go

Below is a JSON parser written in Go. It's just a task I set myself in order to learn Go, which is also the rationale for reinventing this wheel. At the moment, it's not 100% complete but it can ...
6
votes
3answers
196 views

Make my XML Parser in Java using WoodStox run faster and use less memory, or just generally better

I have an XML Parser in Java using WoodStox that I wrote. This parser is going to be parsing through extremely large files, could be 5+GB. The goal of the parser is to convert a nest XML file into a ...
3
votes
1answer
57 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
206 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) ...
8
votes
1answer
112 views

Tokenize a string with escaping

I am learning C and therefore decided to build my own, little shell. Currently I am concerned with input parsing. I want to split a line of text into tokens with delimiters. But it should be possible ...
6
votes
2answers
449 views

C - manually parsing char* into integer

I'm trying to parse a char* into an int without using atoi(). I walk through the string, ...
27
votes
5answers
5k views

High performance txt file parsing

EDIT2: There is a summary below of the findings with new improved code and run time results achieved. Multi threaded follow up has been posted here. I find, in my daily programming, that text-file ...
0
votes
0answers
82 views

Simple React JavaScript Markdown Parser

I needed a simple Markdown parser for my purposes, such that I could turn a small subset of it (just bold, italics, code, links, and a custom poke you can click on) into React components (without ...
0
votes
1answer
38 views

Parsing HTML knock-off for answering queries for values

I wrote a code to parse an HTML knock-off from HackerRank, and I would like a review. Mostly I hope to get better at STL and code style. But any tips would be very welcome. Sample input that I would ...
1
vote
0answers
57 views

String parsing algorithm in Rust

I have written a recursive parsing algorithm for strings with nested brackets (I needed it to solve a molecules to atoms task). I would love to see how I could make ...
5
votes
2answers
145 views

Running out of fuel near Saturn

Optimizing/parsing files into semi-complex data-structures more efficiently To preface, I'd like to say that this code is part of the Advent of Code 2019 solutions I have been working on. ...
5
votes
0answers
96 views

Scanning a string into a list of tokens

Here is my code: ...
3
votes
2answers
63 views

Validating CSV headers against an expected list

My application (legacy code) reads a CSV input file with an expected format with regards to Column names as follows: 1st column - Should say "Marker" 2nd column - Should say "Category" 3rd column ... ...
3
votes
1answer
70 views

Parsing opening hours, discarding insane ones (part of the OpenStreetMap editor)

This code is used to check opening hours data from OpenStreetMap can be handled by an editor app. In case where opening hours is not too complex data is also turned into an usable form. It is a part ...
6
votes
2answers
162 views

Improving a JSON parser for C++

I wrote a JSON parser for C++. It is not particularly fast, efficient or elegant. I'd like to change that and primarily I'd like the code to be more elegant. How do I improve it and get rid of all the ...
7
votes
3answers
250 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
74 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 = ...
2
votes
1answer
98 views

Ruby code to parse and analyze social media stats in json format

What do you think about this code I wrote. It reads several json files ( I attached them as pastebins) and the code outputs summary information calculated from the input. ...
7
votes
2answers
171 views

Simple IP address parser in C

I have written a C function to parse an IP address that should match the regular expression ^\d+.\d+.\d+.\d+ and nothing else. Additionally all bytes are limited to ...
12
votes
4answers
1k views

Parsing C-like code to extract info

I'm reading a file with the following data, ...
3
votes
2answers
99 views

POST variable analysis contains JSON format string PHP

I am verifying certain codes that work well and I don't know what else to optimize in them or what other tests to do: in this case it is a php script that takes the data of the ...
3
votes
0answers
47 views

Implementing chat commands [closed]

I'm new to C++ and I'm writting some kind of chat server and client who talk to each other through commands for learning purposes. I serialize and deserialize these commands using a JSON library. My ...
3
votes
2answers
189 views

Function to prompt and check user input

I'm trying to make a function that asks for a string input and then validates it. If the answer is not correct, the function asks them again for valid input with a while loop. In order to validate ...
4
votes
1answer
56 views

JSON to CSS in JavaScript

I'm working on a JSON to CSS converter in NodeJS, which takes a .json file and generates a .css file with its utility classes from it. .json example ...
6
votes
2answers
251 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 ...
4
votes
1answer
59 views

Rendering the AuthorName using the DOMParser to read XML

I need to concatenate the LastName and Initials and all of that authors affiliations. Is there a better way or faster way to do ...
7
votes
1answer
234 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: ...
3
votes
2answers
133 views

Implementation of tree with different node types and faux-polymorphism in C

I'm currently learning C by working on my first project. It's a calculator with a parser that transforms input into an operator tree. These trees consist of nodes of different types: Operators (inner ...
5
votes
1answer
146 views

Parsing and formatting var_export() string

I have this script to format var_export's result string. The information in the output is good, but I need know if the code performance is good or if it can be improved. https://wtools.io/php-sandbox/...
0
votes
1answer
73 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
210 views

Code that reads/writes to bytes of an ascii-encoded hex string

Problem Statement Given a hexadecimal string (hascii) and its binary specification (a list of byte field names, their offsets, and byte lengths), design classes to parse all byte-fields, cast bytes ...
5
votes
2answers
115 views

Parsing ~100,000 strings and matching them to various classes

I have an app that takes in "commands" in the form of strings that are parsed, and then passed off to a specific class based on the first word in the string. Every ...
7
votes
1answer
97 views

Minimal JSON Parser

Motivation: Partially for fun / learning, but also so I can roll out a custom JSON-like file format for a fighting game I am writing. There are two caveats: you cannot have repeated keys (requires <...

1
2 3 4 5
24