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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UNSTRING Question

Status
Not open for further replies.

REDYPS

Programmer
Jun 12, 2003
12
US
I'm writing a couple of programs to unstring a comma seperated variable (CSV) file.

The first file contains a name and ssn seperated by a comma (no ending delimiter present). This file unstrings as I expect into the two fields, even though there is no ending delimiter.

The second file is supposed to contain 17 fields, however when I save the Excel spreadsheet as a .CSV file half of the records have ending commas and the other half do not. The records with the ending comma read in just fine with the unstring command, but the ones without the ending comma lose the last field. I expected the same result that I got with the first file for records without the ending delimiter.

Any thoughts as to why this happens? I need to fix without the end user manipulating the data file.
 
The UNSTRING will do its job until it encounters a delimiter or the end of the record. In normal circumstances, this should work fine whether you have a comma after the last value or not.

One way I got this to do as you say is happening is by making the last receiving field JUSTIFIED RIGHT.

It would help if we could see your code. Show definitions of sending field and receiving fields as well as the UNSTRING statement.
 
Thanks for the help. The problem was that I was in fact right justifying the fields as they are monetary. I expanded the picture clause and removed the justification.

The FAQ was also extremely helpful.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top