Manipulating and merging rows of large text file using C code

ashutosh08singh's Avatar, Join Date: Oct 2011
Newbie Member
Hi Guys,

We need to write a C code to sort source file based on Product no ,price and then create a new one with a specified format.

Below is the sample data of source file.

Product No. name Country Price Start date End date 101 A US 399 1/1/2011 31-12-2011 102 B UK 499 1/2/2011 31-12-2012 103 C AU 599 1/3/2011 31-12-2013 101 A GB 1099 1/4/2011 31-12-2014 104 D IND 1199 1/5/2011 31-12-2015 101 A UAE 999 1/6/2011 31-12-2016 102 B US 699 1/7/2011 31-12-2017 102 B UK 799 1/8/2011 31-12-2018 101 A US 699 1/9/2011 31-12-2019 103 C GB 899 1/10/2011 31-12-2020 102 B IND 1299 1/11/2011 31-12-2021
First we need to sort the above sample data based on product no and price , then we need to create a new file having product field with different prices in single row using C,

Desired output file --

Product price1 price2 price3 price4 101 399 699 999 1099 102 499 699 799 1299 103 599 899

104 1199



Any sort of help would be highly appreciated.
0
ashutosh08singh's Avatar, Join Date: Oct 2011
Newbie Member
Please ignore previous post as sample data not reflecting correctly. Find the correct format Below :

Product No. name Country Price Start date End date
101 A US 399 1/1/2011 31-12-2011
102 B UK 499 1/2/2011 31-12-2012
103 C AU 599 1/3/2011 31-12-2013
101 A GB 1099 1/4/2011 31-12-2014
104 D IND 1199 1/5/2011 31-12-2015
101 A UAE 999 1/6/2011 31-12-2016
102 B US 699 1/7/2011 31-12-2017
102 B UK 799 1/8/2011 31-12-2018
101 A US 699 1/9/2011 31-12-2019
103 C GB 899 1/10/2011 31-12-2020
102 B IND 1299 1/11/2011 31-12-2021
0
ashutosh08singh's Avatar, Join Date: Oct 2011
Newbie Member
Desired out put file is :

Product price1 price2 price3 price4
101 399 699 999 1099
102 499 699 799 1299
103 599 899
104 1199
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
How far have you got and where are you stuck?
Do you understand the requirements?
Have you decided on an algorithm yet?