long CSV records - VMS solution.

Chris Sharman Chris.Sharman@CCAgroup.co.uk
Thu, 20 Jan 2000 16:18:56 +0000


This is a multi-part message in MIME format.

--------------65E5D0B950886CFE25BFFC5F
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Thanks to all who gave advice on how to generate long csv records.

Suggestions included:
Using subfiles (requires a separate pass to generate matching headings).
Post-processing with some suitable tool:
	Something called paste on Unix (not available on VMS)
	Perl (not installed here, requires knowledge I don't have).

I chose in the end to post-process with TPU (because I know it).
I enclose the TPU, for any other VMS users who'd like it.
It looks for trailing commas, and joins line(s) on until there are none.
Just put it on your system, and invoke as it says at the top (assumes
it's in sys$manager:).
Any problems, let me know.

Regards
Chris

--------------65E5D0B950886CFE25BFFC5F
Content-Type: text/plain; charset=us-ascii; name="long-csv.tpu"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="long-csv.tpu"

! Insert any procedures required BEFORE executable statements
! Note that we are in nodisplay mode:
!	It doesn't make any sense to do anything to do with windows or cursors.
!	We can, however, output messages in the normal way.
!	We also still have a "current position"
!
! Invoke with:
!	$ EDIT/TPU/NODISPLAY/NOSECTION/COMMAND=SYS$MANAGER:LONG-CSV file

procedure do_batch

! This procedure gets called with the current position at the top of the
! main buffer, which contains the input file. The output file has already been
! set, and when this procedure exits, the file will be written.
! This procedure should not create writeable buffers without specifying where
! they should be written to.

	local eject, count, crlf, whitespace, wspace;

	on_error
		if ((error=tpu$_endofbuf) or (error=tpu$_strnotfound))
		then
			message(fao("!UL line!%S joined", count));
			return;
		endif;
	endon_error;

	count := 0;
	loop
		position(end_of(search(',' & line_end, forward, exact)));
		move_horizontal(1);
		append_line;
		position(line_begin);
		count := count + 1;
	endloop;                      
endprocedure;

infile := get_info ( command_line, 'file_name');
outfile := get_info ( command_line, 'output_file' );
if outfile='' then outfile := infile; endif;

main_buffer := create_buffer ( 'main', infile );
set( output_file, main_buffer, outfile );

position ( beginning_of ( main_buffer ) );

do_batch;
exit; ! This won't work if there are modified writeable buffers without
	! output files specified

--------------65E5D0B950886CFE25BFFC5F--

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Subscribe: "subscribe powerh-l" in message body to majordomo@lists.swau.edu
Unsubscribe: "unsubscribe powerh-l" in message to majordomo@lists.swau.edu
This list is closed, thus to post to the list, you must be a subscriber.