Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fixed length text in csv files

Status
Not open for further replies.

JoSno

Programmer
Apr 11, 2003
45
0
0
GB
Is there a way of exporting a spreadsheet to a comma-delimited file so that all fields will be padded out to a fixed length size?

ie

"hello,,there,everyone"

might be (if all set to eight chars)...

"hello , ,there ,everyone"


Cheers!
Jo
 
You would have to have a formula like
=A1 & rept(" ",8-len(A1))
and use it on all of the cells in the workbook - basically create a 2nd sheet that mirrors the 1st sheet but using the formula as above to pad out to 8 characters. Then, simply save the formula sheet as .csv

Rgds, Geoff
[blue]Si hoc signum legere potes, operis boni in rebus Latinus alacribus et fructuosis potiri potes![/blue]
Want the [red]best[/red] answers to your questions ? faq222-2244
 
Hi,

If you have a delimited file(comma, tab, etc), the implication is that it is NOT a fixed length record.

A .prn is called a space delimited file, which is a misnomer because it is a fixed width file and each column IS padded with spaces as required.

Hope this helps :)

Skip,
Skip@TheOfficeExperts.com
 
Thank you for this helpful hint. Sometimes the people you export files to don't want to change!
I had to go further and make sure the decimal places were preserved.
allows a save of a fixed length comma delimited file
G: Format([GAL],"0.000")
GALLONS: Left(" ",(8-Len([G])))+[G]+" "


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top