Code Comments
Programming Forum and web based access to our favorite programming groups.Readers, I have a csv file (greater than 256 columns hence unable to open in spreadsheet) of the following format: column header1, column header2, column header3 1,0.0e0,0.0e0,5e-6 2,0.0e0,0.0e0,6e-7 3,0.0e0,0.0e0,0.0e0 I've never written a script before and I was expecting some sort of command such as delete to exist? Anyway, I want to perform: "if column headerx contains only values of 0.0e0, delete the column (including the column header). Where do I start please? Yours,
Post Follow-up to this messageIn Message-ID:<7c65430f-1e2f-4c52-a832-c8f6a8f0a236@u36g2000prf.googlegroups.co m>, r <inpost@gmail.com> wrote: >I've never written a script before and I was expecting some sort of >command such as delete to exist? Anyway, I want to perform: "if column >headerx contains only values of 0.0e0, delete the column (including >the column header). > >Where do I start please? You start by telling us what platform you're on and what REXX you're using. Most important is whether it's classic or OO, but the name of the actual REXX would be best. Here's the program I run whenever I want to paste the info to help people help me. You might need to skip everything between the first and last blank lines. <code> say '' parse source a say "parse source output:" a say "address():" address() say '' parse version b say "parse version output:" b call rxfuncadd 'sysloadfuncs','RexxUtil','sysloadfuncs' call sysloadfuncs say "McPhee's RegUtil (aka RexxUtil)" SysUtilVersion() call rxfuncadd 'w32loadfuncs','W32util','w32loadfuncs' call w32loadfuncs parse value w32version() with ver file say "McPhee's W32Util" ver "ver" </code> There are no columns in rexx. You have to program it, yourself. You're going to have to read the whole file in. As you go through it, parse out each column. Note any column with other than 0.0e0 (other than the first row). When you get to the end, string together all the data your parsed out, leaving out those columns you don't want. Remember to put the commas back in. -- Arthur T. - ar23hur "at" intergate "dot" com Looking for a z/OS (IBM mainframe) systems programmer position
Post Follow-up to this messageArthur T. wrote: > In > Message-ID:<7c65430f-1e2f-4c52-a832-c8f6a8f0a236@u36g2000prf.googlegroups. com>, > r <inpost@gmail.com> wrote: > > > You start by telling us what platform you're on and what REXX > you're using. Most important is whether it's classic or OO, but > the name of the actual REXX would be best. Here's the program I > run whenever I want to paste the info to help people help me. You > might need to skip everything between the first and last blank > lines. Below is the command terminal output which I hope is helpful: rexx -version Open Object Rexx Interpreter Version 3.1.2 for LINUX Build date: Jun 8 2007 Copyright (c) IBM Corporation 1995, 2004. Copyright (c) RexxLA 2005-2007. All Rights Reserved. This program and the accompanying materials are made available under the terms of the Common Public License v1.0 which accompanies this distribution. http://www.oorexx.org/license.html Syntax is "rexx [-v] filename [arguments]". I'm using mandriva so I used urpmi to install. > > <code> > say '' > parse source a > say "parse source output:" a > say "address():" address() > say '' > parse version b > say "parse version output:" b > > call rxfuncadd 'sysloadfuncs','RexxUtil','sysloadfuncs' > call sysloadfuncs > say "McPhee's RegUtil (aka RexxUtil)" SysUtilVersion() > > call rxfuncadd 'w32loadfuncs','W32util','w32loadfuncs' > call w32loadfuncs > parse value w32version() with ver file > say "McPhee's W32Util" ver > > "ver" > </code> > > There are no columns in rexx. You have to program it, > yourself. > > You're going to have to read the whole file in. As you go > through it, parse out each column. Note any column with other > than 0.0e0 (other than the first row). When you get to the end, > string together all the data your parsed out, leaving out those > columns you don't want. Remember to put the commas back in. > Please excuse my ignorance of your terminology, I am not a programmer. I don't understand this paragraph; do you mean I should manually read each column and write down each column I want to delete? What does "string together all the data your parsed out" mean? Commas are supposed to be re-entered manually?
Post Follow-up to this messageIn Message-ID:<05905b4f-10b7-4d75-a669-6bb55accfb01@e6g2000prf.googlegroups.com >, r <inpost@gmail.com> wrote: >Open Object Rexx Interpreter Version 3.1.2 for LINUX That means that I can't help you as much as, perhaps, others. That's an OO REXX, and I program in classical. >Please excuse my ignorance of your terminology, I am not a programmer. Well, REXX is a programming language. This is probably not the best program to start with if you're not a programmer. Just for jollies, I wrote a quick-and-dirty version of the program. It's not efficient. It has bugs. It's wrong if the first column should be deleted. It also gives wrong output if there's no commas at the ends of the lines. But it might be enough to get you started on a solution. /*REXX exec sample to cannibalize */ call rxfuncadd 'sysloadfuncs','RexxUtil','sysloadfuncs' call sysloadfuncs file = "a.csv" call RegStemRead file, inline. max = inline.0 true = (0=0) false = \true colKeep. = false outline. = '' do i = 1 to max do j = 1 if inline.i = "" then leave j parse var inline.i row.i.j ',' inline.i if i > 1 & row.i.j \== '0.0e' then colKeep.j = true end cols.i = j end do i = 1 to max do j = 1 to cols.i if \ colKeep.j then iterate j outline.i = outline.i || ',' || row.i.j end end outline.0 = max fileout = "b.csv" call RegStemWrite fileout, 'outline.' exit 0 -- Arthur T. - ar23hur "at" intergate "dot" com Looking for a z/OS (IBM mainframe) systems programmer position
Post Follow-up to this messageArthur T. wrote: > In > Message-ID:<05905b4f-10b7-4d75-a669-6bb55accfb01@e6g2000prf.googlegroups.c om>, > r <inpost@gmail.com> wrote: > > > That means that I can't help you as much as, perhaps, others. > That's an OO REXX, and I program in classical. > > > Well, REXX is a programming language. This is probably not > the best program to start with if you're not a programmer. > Thanks, after a search I encountered this article (http:// www.desktoplinux.com/articles/AT3196331606.html) and naively thought "that'll do". > Just for jollies, I wrote a quick-and-dirty version of the > program. It's not efficient. It has bugs. It's wrong if the > first column should be deleted. It also gives wrong output if > there's no commas at the ends of the lines. But it might be > enough to get you started on a solution. > > /*REXX exec sample to cannibalize */ > > call rxfuncadd 'sysloadfuncs','RexxUtil','sysloadfuncs' > call sysloadfuncs > For example, this 'rxfuncadd': I look in the reference guide (section 7451) and I wonder, "how am I supposed to know to use that???" Aren't there any tutorial resources for complete (and I mean complete) novices to start?
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.