Exporting to text file

J

J.Hinson

I'm trying to export data to a space delimited text file,
which will be uploaded to a mainframe dataset for
processing. I need to define an output format, such as
Column1 is position 1-4, column2 is positon 5-15, column3
is position 16-40.

Using the File-Save As - .prn option does not give me
precise control over column positions in the output file.
Can I do this in Excel or should I move the data to Access
and work from there?
 
D

Davi

You can manually adjust the column width for each column to the number of
characters the column should hold. Column1 width should be 4, Column2
should be 11, Column3 should be 25, etc. Change column width by selecting
the column you are re-sizing, then Format, Columns, Width, and input the
column width.

Note, Excel's auto-size feature means it automatically adjusts column width
(and row height) to give your data a little pad so it doesn't truncate on
display. If, when you re-size your columns, the data truncates on display,
shrink your font size a bit and then verify your columns are still sized
correctly (Excel may automatically re-size your columns when you change font
size). If you try to save out the Excel file as .prn-format while the data
is truncated, your resulting .prn-file will have bunk data (test it...you'll
see "#########" where your data should be).

VERY IMPORTANT: If your mainframe reads the file and truly looks for spaces
to splice the data (like Excel does, instead of counting characters) and
your counts below do not include one space for the splice (ex. Column1 is
allowed first 4 positions because maximum char length of data is 3, plus 1
position for space), then you need to make sure your column widths include
not just maximum character count, but 1 extra space for the pad when you
save it out to .prn format. For example, if you use the exact counts I
listed at the top of this message, and you have data that max's out those
counts (ex. Column1 value is "1111" which takes up positions 1-4, and
Column2 value is "99999999999" which takes up positions 5-15) you must
re-size Column1's width to 5 (4 chars. plus 1 space) so that when you save
the file out as space-delimited, the space will be in between for your
mainframe to translate as a splice: 1111_99999999999. Otherwise, your
mainframe will read the first two columns as one string: "111199999999999".
If this applies in your case, then, your new column widths for ALL columns
must be maximum characters + 1.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top