Skip to content

The program reads customer data from a CSV file, sorts the customers by the number of lessons using the quick sort algorithm, and writes the sorted data to a new CSV file.

Notifications You must be signed in to change notification settings

C-Coding-Assignments/Yoga-Studio-Search-Part-2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Customer Sorting by Lessons Program 📊

The program reads customer data from a CSV file, sorts the customers by the number of lessons using the quick sort algorithm, and writes the sorted data to a new CSV file.


Table of Contents 📖

Task 🛠️

Modify the program from Project 7 to use quick sort to sort the customers by the number of lessons. Use the quick sort library function and implement a custom comparison function.


Input and Output 🖥️

Input

  • The input file is named customers.csv and contains customer information formatted as email address (string), number of lessons (int), and name (string), with each customer on a separate line.
  • The program reads the file using fscanf with the format specifier %[^,],%d,%[^\n]\n.

Output

  • The program outputs the sorted data to a file named results.csv.
  • The format of the output file must be the same as the input: email, number of lessons, and name, with each customer on a separate line.

Examples 📋

Example Input (customers.csv)

email1@example.com,5,John Doe
email2@example.com,10,Jane Smith
email3@example.com,3,Bob Johnson

Example Output (results.csv)

email3@example.com,3,Bob Johnson
email1@example.com,5,John Doe
email2@example.com,10,Jane Smith

Explanation:

  • The program reads the customer data from customers.csv, sorts the customers by the number of lessons in ascending order, and writes the sorted data to results.csv.

Requirements ✔️

  1. The program must use quick sort to sort the customers by the number of lessons.
  2. Implement a custom comparison function for qsort.
  3. The program should read data from an input file named customers.csv.
  4. Use fscanf with the format specifier %[^,],%d,%[^\n]\n to read the data into customer structures.
  5. The program must sort the customers by the number of lessons using quick sort.
  6. The program must output the sorted data to a file named results.csv in the same format as the input.
  7. Assume that the file will contain no more than 200 customers and that name and email are no longer than 100 characters.

Usage 🚀

1. Compile the Program:

gcc -o customer_sort customer_sort.c

2. Run the Program:

./customer_sort

3. Input File:

  • The input file customers.csv should be in the same directory as the program.

4. Output File:

  • The program will create an output file named results.csv with the sorted customer data.

About

The program reads customer data from a CSV file, sorts the customers by the number of lessons using the quick sort algorithm, and writes the sorted data to a new CSV file.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages