Adding some <code> ... </code> tag around your code and data would make it easier to read. It would also help if you could give an example of how the CSV-file should look with your data (so we can check if any solution we suggest is correct).Usually reading and writing CSV-files is best done with Text::CSV, but am I right in assuming that it is rather the parsing of the original data that is bothering you?
CountZero A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
| [reply] [d/l] |
| [reply] [d/l] [select] |
| [reply] [d/l] |
It seems you need to understand text parsing. Simply stated, your script assumes one space and a dozen spaces are the same. Obviously this is wrong, and you need to account for each column of data in a hard format.
Whether learning Perl to solve this particular problem is the path to your solution only you can answer. I'm not totally familiar with AWK's full set of features, but I do know there are some fine columnar tools in 'cut'.
| [reply] |
Thank you all for your help. I should learn Perl or Awk, for that matter, but I find myself needing a quick tool for specific problem that I'll probably never require again. Your suggestions, especially the one on my faulty assumptions of the column width, have been quite helpful. While I don't the solution in hand, you have put me on the right path. I apologize again for the poor formatting and thank you for your prompt and authoritative responses. | [reply] |