[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

extending out dates

Posted on 2011-10-18
4
Medium Priority
?
328 Views
Last Modified: 2012-05-12
Hello

I have a csv file where some of the data needs extending based on what is in current file.
Sample data as follows.........

Cpy                         Period         Repeats       Date                    Value
A001-20110130       Monthly          3              01/02/2011         100
A001-20110330       Null                0              01/04/2010           45
A004-20110130       Quarterley      2              10/02/2011         234
A005-20110130       Null                0              01/06/2011         100
etc
so, based on above data I need to add rows based on "Period & Repeats" columns having values.
Row1 will now have 3 more rows added and the only thing that will change is the date column.
Row 3 will have 2 more rows added and again only the date value will change. The idea is to extend out the dates based on columns "Period & Repeats." Now, my new data set based on the above rules should read as follows....

Cpy                         Period         Repeats       Date                    Value
A001-20110130       Monthly          3              01/02/2011         100
A001-20110130       Monthly                          01/03/2011         100
A001-20110130       Monthly                          01/04/2011         100
A001-20110130       Monthly                          01/05/2011         100
A001-20110330       Null                0              01/04/2010           45
A004-20110130       Quarterley      2              10/02/2011         234
A004-20110130       Quarterley                      10/05/2011         234
A004-20110130       Quarterley                      10/08/2011         234
A005-20110130       Null                0              01/06/2011         100

Hope this makes sense.

Regards

0
Comment
Question by:philsivyer
  • 2
4 Comments
 
LVL 6

Accepted Solution

by:
billfusion earned 2000 total points
ID: 36990538
I don't know ruby but may be the logic bit can help you:
Open read file
open write file /* temporary file to create new content*/
write header in writeFile
until eof
    read line
    split line content variables  (Cpy, Period, Repeats, Date, Value)
    set tmpIndex = 0
    set repeatCount = repeats
    while tmpIndex <= repeats
        write value in writeFile (Cpy, Period, Repeats, Date, Value)
        increment Date by one month
        set repeats to null
        increment tmpIndex
    end while
end

Open in new window

0
 

Author Comment

by:philsivyer
ID: 37003302
Thanks - but, any rubyists out there?
0
 
LVL 24

Expert Comment

by:fridom
ID: 37068516
Now where's your try?
0
 

Author Comment

by:philsivyer
ID: 37152015
OK

I now have a solution
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently rediscovered rails when I needed a holiday project and decided to build a management dashboard for the company where I work.  With it being a project done in my free time, I could focus my time on learning the basics rather than trying to…
In Ruby, Call or invoke a API DLL library is easily via Win32API class, win32-api gem or other gems. For general DLL API call, there are quite a few references, some good tips list below: http://www.rubytips.org/2008/05/13/accessing-windows-api-fro…
Integration Management Part 2
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses
Course of the Month20 days, 10 hours left to enroll

868 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question