Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Manipulating and merging rows of large text file using C code (http://www.go4expert.com/forums/manipulating-merging-rows-text-file-t26858/)

ashutosh08singh 6Oct2011 12:19

Manipulating and merging rows of large text file using C code
 
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.

ashutosh08singh 6Oct2011 12:27

Re: Manipulating and merging rows of large text file using C code
 
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

ashutosh08singh 6Oct2011 12:28

Re: Manipulating and merging rows of large text file using C code
 
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

xpi0t0s 7Oct2011 03:30

Re: Manipulating and merging rows of large text file using C code
 
How far have you got and where are you stuck?
Do you understand the requirements?
Have you decided on an algorithm yet?


All times are GMT +5.5. The time now is 08:56.