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
27 views

C: 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 ...
-3
votes
0answers
13 views

Parsing text from multiple downloaded htmls [closed]

I want to extract from a directory (where i have stored my downloaded htmls), all the "executives". In this directory their are app 1.000 htmls ( (example: https://www.dropbox.com/s/uka24w7o5006ole/...
6
votes
2answers
430 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, ...
26
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
70 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
32 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
48 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
141 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
91 views

Scanning a string into a list of tokens

Here is my code: ...
3
votes
2answers
56 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
68 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
142 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
151 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
71 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
84 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
164 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
46 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
188 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
55 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 ...
3
votes
0answers
38 views

OOP parsing for DB dump XML Python

I am parsing large XML (DB dump). So, the content looks like many different objects with their properties and dependencies (foreign keys). My way to do it - using lxml.etree (iterparse): ...
6
votes
2answers
245 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
232 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
116 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
120 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
68 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
200 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
112 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
84 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 <...
7
votes
4answers
113 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
48 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
49 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
2answers
150 views

C++ Building Parse Tree with Boost and Modern C++

I am writing a parser. To build up the tree, I need to find the correct type for my node based on text from my language input file. Right now, I have a map from a string (the node name) to a factory ...
4
votes
1answer
80 views

Parse data into an array of structs

I'd had a hard time getting this to work. I’d like to parse a file containing data and copy this data into a struct. The data file (test.dat) looks like this: <...
6
votes
1answer
753 views

Rust Torrent Parser

I wrote a simple Torrent file parser. The following program accepts a file and builds a Torrent structure based on the contents on the file. If the file is invalid, the app crashes (as intended). It'...
3
votes
1answer
94 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 ...
2
votes
1answer
36 views

Apply smiley replacement filter to Pandoc but not in code segments

I wrote a filter for pandas that converts :-) to but not in inline code or code blocks. Pandoc makes it so the ...
2
votes
0answers
39 views

Ensuring a valid JavaScript string in security-critical application

I'm writing an application where users can write custom expressions which are then converted to JavaScript functions and executed. The expressions are used for filtering and sorting data from a ...
4
votes
3answers
372 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
61 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 ...
3
votes
1answer
117 views

Function to parse VB.NET Like pattern

VB.NET has a Like operator with a paradigm similar to the standard SQL LIKE expression (SQL Server, SQLite, MySQL), but with a ...
9
votes
6answers
903 views

Parse a simple key=value config file in C

Write a program that should read a file formatted strictly like this below: $ cat sample bingo=2 bingo2=939 bingo3=text The left and right side of ...
4
votes
1answer
73 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 ...
2
votes
0answers
33 views

Command String Parser

I'm working on a library that, in essence, splits a string at whitespace, with extra rules: Consecutive whitespace is collapsed, and trimmed at the start and end. Whitespace wrapped in quotes is not ...
4
votes
1answer
99 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 ...
11
votes
3answers
2k views

Convert a string like 4h53m12s to a total number of seconds in JavaScript

At the moment I have this: ...
1
vote
0answers
32 views

git status parser using regular expressions in javascript

I'm looking for improvements of a code that filter the output of git status --ignored and git status --ignored -bs commands. I ...
4
votes
2answers
241 views

Parser for STL stereolithography data files [closed]

I'm parsing STL files to load the coordinates. My code is: ...