Reformat file input/output

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tudyfruity18
    New Member
    • Sep 2007
    • 8

    Reformat file input/output

    I have to write a program that will reformat the data files given to me and create a new data file for each city. The desired output would be the cities name followed by the year( fixed four digits), monthly rainfall-12 months(Jan-Dec), and total rainfall for that year(4 digit). In order to format the year I must drop the first 6 months of the first year and the last six months of the last year. Because its formatted as July through June. I don't know where to start.
  • Meetee
    Recognized Expert Contributor
    • Dec 2006
    • 928

    #2
    Originally posted by tudyfruity18
    I have to write a program that will reformat the data files given to me and create a new data file for each city. The desired output would be the cities name followed by the year( fixed four digits), monthly rainfall-12 months(Jan-Dec), and total rainfall for that year(4 digit). In order to format the year I must drop the first 6 months of the first year and the last six months of the last year. Because its formatted as July through June. I don't know where to start.
    What is the format of your input file? Can you post it here exactly?

    What I can see from here is you can find the minimum year and then start by searching the 7th month and so on. Then when the maximum year comes just do the same upto 6th month.

    Regards

    Comment

    • sicarie
      Recognized Expert Specialist
      • Nov 2006
      • 4677

      #3
      Originally posted by tudyfruity18
      I have to write a program that will reformat the data files given to me and create a new data file for each city. The desired output would be the cities name followed by the year( fixed four digits), monthly rainfall-12 months(Jan-Dec), and total rainfall for that year(4 digit). In order to format the year I must drop the first 6 months of the first year and the last six months of the last year. Because its formatted as July through June. I don't know where to start.
      You do need to start with the format of your input file. Using file IO, you should be able to read everything into the "group" of variables you have created for it (ie months, days, years, rainfalls, totals). Once you have read them in and know what variables are holding what where (ie, if it's a month array, does it start with Jan, or does it start with Dec?), you can format the output however you want.

      Comment

      Working...