Re: Export Text File consisting header and table

Tech-Archive recommends: Fix windows errors by optimizing your registry



=?Utf-8?B?TkMgQmVhY2ggQnVt?= <NCBeachBum@xxxxxxxxxxxxxxxxxxxxxxxxx>
wrote in news:A0A31AA8-2376-4DEA-827D-37544289B174@xxxxxxxxxxxxx:

> Frist line is a header record such as "this is the header".
> The second line then contains the rows of a data table in a specific
> set number of characters with a filler at the end to make a full 80
> character record.

It's not very hard:

open FileName for output as #OutFileH

print #outfile, "This is the header"

do while not rst.EOF
print #outfile, padright(rst!First, 18));
print #outfile, padright(rst!Second, 12));
print #outfile, padright(rst!Third, 9));
' finished row
print #outfile

rst.movenext
loop

close #outfile
rst.Close


Oh yes, you'll need something like this too:

public function padright(Something as variant, PadWidth as integer) _
as string

dim temp as string

if not isnull(something) then
' standard right-padding algorithm
' use default data type conversion: should really be a lot
' more defensive e.g. with decimal points, date formats,
' booleans etc etc etc.
temp = Right(space(padwidth) & CStr(Something), PadWidth)

else
temp = Str(padwidth,"*")

end if
padright = temp
end function

Hope that helps


.



Relevant Pages

  • Re: Perl script to clean up file -- Dont know if it can be done
    ... > has a header and footer, as well as page breaks, this is all in ASCII ... stuff and doing the transformation). ... my $outfile = 'outfile'; ...
    (comp.lang.perl.misc)
  • Re: Merge part of CSV files
    ... They all have a header ... line, a single data line and footer line, but it is only the data line ... footer lines are not required at all. ... print OUTFILE counter, line ...
    (comp.lang.perl.misc)
  • Re: Howto Extract PNG from binary file @ 0x80?
    ... I've discovered a weird thing when changing header = infile.readto ... #def pngcopy(infile, outfile): ... # size, cid = struct.unpack("!l4s", chunk) ...
    (comp.lang.python)
  • Re: Importing data into a table
    ... Use Open and Line Input# to filter the original text file into a temp ... dim inFile as integer ... dim outFile as integer ... dim readText as string ...
    (microsoft.public.access.modulesdaovba)