Questions tagged [parsing]
Use this tag for code that parses its input, or that is source for a parser generator such as yacc or lex.
1,319
questions
7
votes
2
answers
1k
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
3
answers
4k
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
1
answer
1k
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 = ...
3
votes
1
answer
123
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
2
answers
949
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
4
answers
2k
views
Parsing C-like code to extract info
I'm reading a file with the following data,
...
3
votes
2
answers
126
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
0
answers
61
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
2
answers
234
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
1
answer
122
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
2
answers
361
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
1
answer
70
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
1
answer
314
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
2
answers
633
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
1
answer
781
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
1
answer
101
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
4
answers
509
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
2
answers
172
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
1
answer
317
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
4
answers
184
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
1
answer
620
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 ...
9
votes
1
answer
142
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
2
answers
1k
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
1
answer
1k
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:
<...
5
votes
1
answer
1k
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'...
4
votes
1
answer
2k
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
1
answer
52
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
0
answers
50
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
3
answers
411
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
2
answers
169
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
1
answer
166
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
6
answers
10k
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
1
answer
80
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
0
answers
42
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
1
answer
168
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
3
answers
3k
views
Convert a string like 4h53m12s to a total number of seconds in JavaScript
At the moment I have this:
...
1
vote
0
answers
51
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
2
answers
1k
views
Parser for STL stereolithography data files [closed]
I'm parsing STL files to load the coordinates. My code is:
...
4
votes
1
answer
178
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
4
answers
2k
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
1
answer
228
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
5
answers
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
1
answer
352
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
2
answers
2k
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 ...
3
votes
0
answers
459
views
Reading and parsing binary file from CAEN Digitizer (written by WaveDump)
Preliminaries
I have CAEN Digitizer N6720A and use WaveDump software for the data acquisition and recording.
As a result of data recording this software produces a binary file in which the sequence ...
6
votes
2
answers
219
views
Compact command line argument parser : Revisited
This question is a follow up to my previous one which can be found here.
The user dfhwze suggested me to look into compiler construction and recommended me to write a lexer and a parser that would ...
-2
votes
1
answer
107
views
Parse header information [closed]
Concrete Context: I parse the header information from curl execution/request and get the array named $headerARR. At this point it looks like the next example, but ...
2
votes
1
answer
420
views
Compact command line argument parser
So, I decided to write my own little command line argument parser for various other projects I work on. I am aware that there are many good command line parser libraries, but I did wrote my own anyway ...
3
votes
1
answer
1k
views
A simple TCP command executer
In https://github.com/pc-magas/tcp_command as an attempt to learn C++ I made a simplistic TCP server in GNU/Linux that will receives simple "commands" in ASCII form. Each command ends with '\n' and a ...
3
votes
1
answer
153
views
Parsing Game Entities
Could use some help with my presentation in Software Development. I'm presenting how I reworked a game's parser (SpaceTaxi). Basically we take in a .txt file with ASCII characters and convert them ...