Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • 3
    HI Kaitlin! This is a tiny bit too broad, because we're not a free code-writing service. We love to help, though! Can you explain what you've tried and where you're stuck? To me, this looks like if you want it in Python, you are probably somewhat familiar in Python and could easily read in the lines from a file, split each line across the space characters, and then just write the elements you need into the right file. Have you tried something similar? Commented Oct 22, 2024 at 15:58
  • (1) Rather than showing 34 lines of input data that are (AFAICT) identical, features-wise, it would be better to show a sufficient representative sample of input data and show what you want to get as output.   (1a) In particular, what do you want the 2024 file to look like (given that you, presumably, have data for some, but not all, months of the current year)?  In general, what do you want to happen if some month(s) are missing?   (2) What do you mean by “each initial file”?   (3) Do any of your data values include space(s)?  … (Cont’d) Commented Oct 22, 2024 at 17:04
  • (Cont’d) … (4) Are you saying that you have 3000+ files of approximately 537 lines each (one per month, January 1980 through the present), and you want to end up with 45 files (one per year) of 3000+ lines each?  Please clarify. Commented Oct 22, 2024 at 17:04
  • Yes, I have 3000+ files that I need to pare down to around 45 files (one per year of data). Each file would include the following columns in each line. IDENTIFICATION, YEAR, JANUARY MONTH CODE (1), JANUARY PRECIPITATION, FEBRUARY MONTH CODE (2), FEBRUARY PRECIPITATION, MARCH MONTH CODE (3), MARCH PRECIPITATION...... Commented Oct 22, 2024 at 17:19
  • Please edit your question and include everything people asked for in the comments. We need to see representative input, and the output you want from that example input. We also need to see the file names so we don't waste your time or ours giving solutions that don't work. Commented Oct 22, 2024 at 17:45