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
1
vote
1answer
45 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
123 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
160 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
105 views

Scanning a string into a list of tokens

Here is my code: ...
3
votes
2answers
324 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
113 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 ...
7
votes
2answers
597 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
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
247 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
105 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
222 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
113 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
50 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
199 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
60 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
289 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
60 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
238 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
282 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
326 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
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
262 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
120 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
136 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
150 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
224 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
2answers
658 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
359 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
871 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
557 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
43 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
42 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
387 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
94 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
126 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 ...
11
votes
6answers
5k 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
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 ...
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
124 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
34 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
485 views

Parser for STL stereolithography data files [closed]

I'm parsing STL files to load the coordinates. My code is: ...
4
votes
1answer
109 views

Wavefront 3D Obj parser/viewer

For learning Rust I decided to make a 3D .obj viewer. I wrote a simplified OBJ parser without materials that only supports triangles. Considering I'm completely new to Rust and don't really know ...
6
votes
4answers
1k views

Parse source code of the RAPID robot-automation language

I am new to C, and I have very little formal education on programming (Although I am currently in college). I work as a Robot Automation technician, and me and my team are required to document a lot ...
2
votes
1answer
169 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 ...
18
votes
5answers
4k views

Speeding up thousands of string parses

I have a mapping application which takes string arguments in the form of string arrays. I parse these and then perform an action on the map. One of these is ...
4
votes
1answer
117 views

Email Generator

I've made a email generator, that uses a HTML template and replaces keywords in the template with information taken from a database. I'm looking to see if there is a way to improve the coding. ...
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 ...

1 2
3
4 5
25