Menu

Executive Programs

Workshops

Projects

Blogs

Careers

Student Reviews


For Business / Universities

Corporate Training

Hire from US

Academic Up-skilling



All Courses

Choose a category

Loading...

All Courses

All Courses

logo

Mechanical

Uploaded on

05 Dec 2022

Common Problems In File Parsing Projects

logo

Skill-Lync

In this article, based on one of the student projects of Skill-Lync alumni, you will get a clear-cut idea of the common mistakes encountered during file parsing. But before that, let’s understand what file parsing is in brief.

What is File Parsing?

Parsing, syntax analysis, or syntactic analysis is the process of examining a string of symbols that adhere to formal grammar norms, whether in normal language, computer languages, or data structures. The word "parsing" is derived from the Latin word pars (orationis), which means "part (of speech).

In computer languages, parsing refers to the syntactic breakdown of the input code into its 

parts to make creating compilers and interpreters easier. It can be applied to separation or a split.

A file is parsed by reading in some kind of data stream and creating an in-memory model of its semantic content. This seeks to make it easier to change the data in some way.

of the common errors encountered while trying to solve the project.

Kinds of File Parsing

Essentially, the parser's job is to assess whether and how the input may be derived from the grammar's start symbol. There are essentially two ways to accomplish this:

Top-down parsing: It can be considered an effort to locate the input stream's left-most derivations by looking for parse trees using a top-down expansion of the provided formal grammar rules. Intake of tokens occurs left to right. By encompassing all possible right-hand sides of grammatical rules, the inclusive choice is utilised to deal with ambiguity. This is known as the primordial soup strategy. Primordial soup dissects the components of sentences like sentence diagramming. 

Bottom-up parsing: A parser might attempt to rewrite the input from the start symbol, starting with the input itself. The parser searches for the most fundamental items first, followed by elements that contain these, and so on. Examples of bottom-up parsers are LR parsers. Shift-Reduce parsing is another name for this kind of parser.

Common Problems During File Parsing

  • Inconsistency when comparing 2 arrays (element number inconsistency).

This error is encountered when students compare 2 arrays of the same data type with a different number of elements.

The code snippet below is to compare 2 string arrays elementwise and tells if each element is a match or mismatch.

The result of the code is as follows,

As you can see above, since the number of elements in the 2 arrays compared is different, the error is displayed as the program tries to compute for the 5th iteration where array A has no value.

  • Inconsistency when comparing 2 arrays (array type inconsistency).

A similar error can also occur when students try to compare 2 arrays with similar elements and dimensions, but the array type is different.

The example below is a program to compare 2 arrays with similar dimensions and elements but stored in different array types.

In Array A values from 1 to 5 are stored in a character array.

In Array B values from 1 to 5 are stored in a double array.

The result of the code is as follows,

As you can see clearly, despite the values stored in both arrays being the same when compared elementwise, all the comparison iterations fail and mismatch.

This is why comparisons should primarily be made between only similar data types.

Features of the String Compare function (strcmp)

The string compare function is a special function that has features that supersede the simple "if" function, Some of these capabilities are demonstrated below,

strcmp() can compare between cell and character datatypes

The code snippet below is used to compare between to arrays of type cell (B) and type character (A), Using the "if" command to directly compare between the 2 arrays will result in false clause.

But using the strcmp() let us observe the result.

The result of the code snippet above is below,

From the result above we can observe 2 things,

The result is positive irrespective of the inconsistency of the data type and array dimensions (i.e) Array A is of type character and has a length of 12 while Array B is of type cell and has a length of 1.

The cell array stores all the values are given in one string in one cell regardless of the data types.

Strcmp() cannot compare between character and double(numerical) data types

Despite strcmp() having superiority to the simple "if" statement, it still cannot compare between character and double data types.

The code snippet given below compares the same elements stored in 2 different array types (double vs character),

Array A is of datatype double.

Array B is of datatype character.

The result will be as displayed below,

From here, it is clear that regardless of the consistency between the two arrays with regard to elements and length the strcmp() still cannot compare a character and a double datatype.

The "while" command does not automatically update to the next line on every iteration when reading a file 

The "while", when used in reading a file, cannot automatically update to the next line, it needs to be explicitly mentioned to update and read a new file every time.


Author

author

Navin Baskar


Author

blogdetails

Skill-Lync

img

Continue Reading

Related Blogs

Moving Frame of Reference

A Moving Reference Frame (MRF) is a very straightforward, reliable, and effective steady-state Computational Fluid Dynamics (CFD) modeling tool to simulate rotating machinery. A quadcopter's rotors, for instance, can be modeled using MRFs.

Mechanical

12 May 2023


Analysis Settings in Ansys Software

Analysis settings in Ansys are the parameters which determine how the simulation should run.

Mechanical

08 May 2023


Comparing the Explicit and Implicit Methods in FEA

In Ansys, the analysis settings play a very important role in converging the solution and obtaining the results. These involve settings about the timestep size, solver type, energy stabilization etc.

Mechanical

06 May 2023


Tensors, Stress, and 2D Meshing: A Primer for Beginners

A tensor is a mathematical object that describes a geometric relationship between vectors, scalars, and other tensors. They describe physical quantities with both magnitude and direction, such as velocity, force, and stress.

Mechanical

05 May 2023


Reynold's law of Similarity

The Reynolds number represents the ratio of inertial to viscous forces and is a convenient parameter for predicting whether a flow condition will be laminar or turbulent. It is defined as the product of the characteristic length and the characteristic velocity divided by the kinematic viscosity.

Mechanical

04 May 2023



Author

blogdetails

Skill-Lync

img

Continue Reading

Related Blogs

Moving Frame of Reference

A Moving Reference Frame (MRF) is a very straightforward, reliable, and effective steady-state Computational Fluid Dynamics (CFD) modeling tool to simulate rotating machinery. A quadcopter's rotors, for instance, can be modeled using MRFs.

Mechanical

12 May 2023


Analysis Settings in Ansys Software

Analysis settings in Ansys are the parameters which determine how the simulation should run.

Mechanical

08 May 2023


Comparing the Explicit and Implicit Methods in FEA

In Ansys, the analysis settings play a very important role in converging the solution and obtaining the results. These involve settings about the timestep size, solver type, energy stabilization etc.

Mechanical

06 May 2023


Tensors, Stress, and 2D Meshing: A Primer for Beginners

A tensor is a mathematical object that describes a geometric relationship between vectors, scalars, and other tensors. They describe physical quantities with both magnitude and direction, such as velocity, force, and stress.

Mechanical

05 May 2023


Reynold's law of Similarity

The Reynolds number represents the ratio of inertial to viscous forces and is a convenient parameter for predicting whether a flow condition will be laminar or turbulent. It is defined as the product of the characteristic length and the characteristic velocity divided by the kinematic viscosity.

Mechanical

04 May 2023


Book a Free Demo, now!

Related Courses

https://d28ljev2bhqcfz.cloudfront.net/maincourse/thumb/introduction-hev-matlab-simulink_1612262875.jpg
Introduction to Hybrid Electric Vehicle using MATLAB and Simulink
4.8
23 Hours of content
Electrical Domain
Know more
https://d28ljev2bhqcfz.cloudfront.net/maincourse/thumb/vehicle-dynamics-matlab_1636606203.png
4.8
37 Hours of content
Cae Domain
Showing 1 of 4 courses
Try our top engineering courses, projects & workshops today!Book a Live Demo