The comma-separated values csv file format is a delimited

Assignment Help Computer Engineering
Reference no: EM13347718

The comma-separated values (CSV) file format is a delimited data format, commonly used as a portable representation of database-type data. Files of CSV format have fields separated by the comma character and records separated by newlines. For this programming assignment, you are going to use flex to write a converter that transforms any legal CSV file into an HTML table.

We will use the following rules extracted from RFC 4180 (https://tools.ietf.org/html/rfc4180) to define CSV:

1. Each record is located on a separate line, delimited by a line break (\n). For example:

Name,Birth Date,Career Titles,Highest Ranking\n
Agassi,04/29/1970,60,No. 1\n

2. Within each record, there may be one or more fields, separated by commas. Each line should contain the same number of fields throughout the file. Spaces are considered part of a field and should not be ignored. Empty fields are allowed. The last field in the record must not be followed by a comma. For example:

Name,Birth Date,Career Titles,Highest Ranking\n
Becker,06/16/1981,,No. 112\n

3. Each field may or may not be enclosed in double quotes. If fields are enclosed with double quotes, there is no space between double quotes and commas or line breaks.

For example:

Name,Birth Date,Career Titles,Highest Ranking\n
Agassi,"04/29/1970",60,"No. 1"\n

4. Fields containing line breaks (\n), double quotes, and commas must be enclosed in double-quotes. For example:

Name,Birth Date,Career Titles,Highest Ranking\n
"Agassi, Andre",04/29/1970,60,"No. 1\n

5. A double-quote appearing inside a field must be escaped by preceding it with another double quote. For example:

"Peter ""Pete"" Sampras",08/12/1971,64,No. 1\n

For this assignment, you will use flex to compose a format converter. For any legal CSV file, your converter should translate it to an HTML file containing a single table. The specific requirements are:

1. Each field in the CSV file corresponds to a single cell of the HTML table, enclosed by <td> and </td>.

2. Each record in the CSV file corresponds to a single row of the HTML table, enclosed by <tr> and </tr>.

3. Double quotes that are used to enclose a field should be eliminated and not appear in the generated HTML table.

4. Any double-quote inside a field should be reserved, but the one preceding it as an escape operator should be eliminated.

5. Any line break (\n) inside a field should be converted to a <br> in the HTML file.

6. If the < or > characters occur as part of the data, they should be translated into the strings &lt; and &gt; respectively. This will prevent data that looks like an HTML tag from acting like one.

7. All other content inside a field should be directly copied into the HTML table.

8. If the field is empty, you should enter the character &nbsp; (non-breaking space) in the HTML table cell. Empty cells do not display neatly in HTML tables.

9. You will need to generate additional tags to complete the HTML table (<table> and </table>). Also, the generated HTML table must have visible borders around each table cell. For example, use <table border=3> to set the table border to be 3 pixels.

10. Other HTML tags (<html></html>, <body></body>) are optional.

11. You can assume all input files are legal CSV files defined as above and there is no need to report any illegal input.

12. The converter should read its input from stdin and write to stdout. This is already the default in flex. For example, you should be able to type %mycsv2html <inputfile >outputfile to dump the generated table into outputfile. You can then check the generated HTML file by opening it by a web browser.

For information on Lex and Yacc, look at the Niemann book which is linked to from the texts page, and there are additional links in a folder dedicated to this topic.

Reference no: EM13347718

Questions Cloud

Methods are commonly used to break a problem down into : methods are commonly used to break a problem down into small manageable pieces. a large task can be broken down into
This is a simulation of rolling dice actual results : this is a simulation of rolling dice. actual results approach theory only when the sample size is large. so we will
Problem 1 in a study relating college grade point average : problem 1 in a study relating college grade point average to time spent in various activities students are asked how
You will build a recursive-descent parser for the right : you will build a recursive-descent parser for the right recursive version of the classic expression grammar found in
The comma-separated values csv file format is a delimited : the comma-separated values csv file format is a delimited data format commonly used as a portable representation of
The virgin brand entered the australian aviation market in : the virgin brand entered the australian aviation market in 2000 in competition with qantas and the other major airlines
Research paper the law laid down in soloman v soloman and : research paper the law laid down in soloman v. soloman and co. is usually considered the source on the basis of which
You have been asked by the president of your company to : you have been asked by the president of your company to determine the proposed acquisition of a new special-purpose
The corporate finance projectname of the company netflix1 : the corporate finance projectname of the company netflix1. leverage and coverage ratiosnbspmost recent fiscal

Reviews

Write a Review

Computer Engineering Questions & Answers

  Create the following symbolic equations

Create the following symbolic equations.

  Describe the function and purpose of each component

describe how the components are related to each other. For example, does the component you are describing depend on another to operate? Is it connected to the network physically or wirelessly.

  Make procedures are followed by database development teams

What is the key reason(s) that make many developers skip over the documentation and proper design procedures? As a manager, how do you ensure that the proper database design procedures are followed by database development teams?

  Average access time of memory system

The access time to cache is 30 nanoseconds. The access time to memory is 120 nanoseconds. The data bus between cache and main memory is 128 bits wide. The hit rate on cache is 95%. 25% of the cache blocks are dirty.Specify the average access time o..

  Make a client/property database using microsoft access

The file New Database window opens, then type the word Client as the name for this file where cursor is blinking, then click the create bottom.

  How can store configuration information on a motherboard

Why do you think the trend is to store configuration information on a motherboard in CMOS setup  than by using jumpers or switches.

  Basic strategic planning questions

What the basic strategic planning questions must be addressed for the infrastructure? Suppose that x and y are “int” variables and “ch” is a char variable.

  How to use hexadecimal or octal nowadays

What kinds of data formats are there? Why are there so many? Can you tell from looking at a string of bits exactly what the data represents?

  Create the web page and put spaces between the links

design a Heading that is centered on the page.create the Web page and put spaces between the links.

  Provide users optimum signal strength and availability

Name one major advantage and one major disadvantage of "Simple Network Management Protocol (SNMP)" and describe a short scenario in that a company would find this tool the ideal choice for monitoring their WLAN.

  Define the way in which a person writes or sends e-mails

explain a scenario in which someone displayed bad netiquette. How did someone react to receiving the email? what could the sender have done differently to display good netiquette.

  In short define asynchronous communications

express packet switching and the benefits of packet switching. What are examples of packet switching networks.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd