Manipulating and merging rows of large text file using C code

Discussion in 'C' started by ashutosh08singh, Oct 6, 2011.

  1. ashutosh08singh

    ashutosh08singh New Member

    Joined:
    Oct 6, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    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.
     
  2. ashutosh08singh

    ashutosh08singh New Member

    Joined:
    Oct 6, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    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
     
  3. ashutosh08singh

    ashutosh08singh New Member

    Joined:
    Oct 6, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    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
     
  4. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    How far have you got and where are you stuck?
    Do you understand the requirements?
    Have you decided on an algorithm yet?
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice