Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A social networking company, Chirper, has contracted you to parse their CSV data of individual Chirps. Each line of CSV in their file is structured

A social networking company, Chirper, has contracted you to parse their CSV data of individual Chirps. Each line of CSV in their file is structured as "USERNAME,MESSAGE,DATE". Implement a function parse_chirp which verifies that each input string matches this format by ensuring that: There are 3 tokens in the string corresponding to the 3 properties above. The username must begin with @. The third token should be in the format MM/DD/YYYY (hint: tokenize this as well). The function should return 0 if the CSV string is valid, and 1 otherwise. Your program should read CSV strings until the string "END" is read as input. Print all valid strings to stdout followed by a line indicating how many invalid strings were entered. Do not use file operations for this assignment. Hint: A continuous stream of strings can be entered by constructing a CSV file using the properties defined above and putting each entry (USERNAME,MESSAGE,DATE) on a newline. You can then redirect the contents of the file into your program (./a.out < file.csv) You can use a character array with a buffer size of 1024 for reading each line using fgets. Each chirp can be no longer than 140 characters. You may not use any library specifically for parsing CSV. Test your code using the file chirp_data.csv, available through Canvas. You should be able to input it to your program using redirection. Save your code as parse_chirps.c.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Database Programming With Visual C# .NET

Authors: Ying Bai

1st Edition

0470467274, 978-0470467275

More Books

Students also viewed these Databases questions