Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

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 (http://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 and .

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

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
in the HTML file.

6. If the < or > characters occur as part of the data, they should be translated into the strings < and > 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   (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 (

and
). Also, the generated HTML table must have visible borders around each table cell. For example, use to set the table border to be 3 pixels.

10. Other HTML tags (, ) 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 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.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9717335

Have any Question?


Related Questions in Computer Engineering

Software engineeringyou are a webapp designer for

Software Engineering You are a WebApp designer for FutureLearning Corporation, a distance learning company. You intend to implement an Internet-based "learning engine" that will enable you to deliver course content to a ...

An array a1 n is said to have a majority element if more

An array A[1 . . . n] is said to have a majority element if more than half of its entries are the same. Given an array, the task is to design an efficient algorithm to tell whether the array has a majority element, and, ...

The following is historical data on the us dollar -

The following is historical data on the U.S. dollar - Canadian dollar exchange rate: Date U.S./Canadian  Canadian/U.S. 1/20/2016 0.68 1.46 9/6/2018 0.76 1.32 Calculate the percentage change in the exchange rate over this ...

The gravitational attraction between any two objects in the

The gravitational attraction between any two objects in the universe is given by the following formula: Force of Gravity = (G * m * n) / r 2 Where  m  and  n  are masses of the objects in kilograms,  r  is the distance b ...

Question this assignment consists of two 2 sections a

Question: This assignment consists of two (2) sections: a project introduction and a project plan. You must submit both sections as separate files for the completion of this assignment. Label each file name according to ...

Patient patientid familyname givenname address suburb state

PATIENT (PatientID, FamilyName, GivenName, Address, Suburb, State, PostCode) DOCTOR (ProviderNo, Name) ITEM (ItemNo, Description, Fee) ACCOUNT (AccountNo, ProviderNo, PatientID, TreatmentDate) ACCOUNTLINE (AccountNo, Ite ...

Sutures sutures are strands or fibers used to sew living

Sutures: Sutures are strands or fibers used to sew living tissue together after an injury or an operation. Packages of sutures must be sealed carefully before they are shipped to hospitals to prevent contamination. The p ...

You are running a small manufacturing shop with plenty of

You are running a small manufacturing shop with plenty of workers but with a single milling machine. You have to produce n items; item i requires m i machining time first and then p i polishing time by hand. The machine ...

Mary kate is a project manager in the it department for a

Mary Kate is a project manager in the IT department for a university. She has been asked to manage a project to create faculty intranet. The university has multiple campuses in various locations, and professors and other ...

Two manufacturing firms are located on the banks of the

Two manufacturing firms are located on the banks of the Crimea River. Riditna Paper withdraws river water for use in its paper mill, and returns it, along with waste effluent, back into the river. (Effluent is a co-produ ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As