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

Delimited With tab 1

Status
Not open for further replies.

AidenMc

Programmer
Sep 19, 2002
58
GB
Hi all ,
Just a quick question that I am hoping someone might have the answer to. I am outputting a file to sdf format but I also need it to be tab delimited ie
COPY TO filename TYPE SDF, works fine but if I add the DELIMITED WITH TAB it causes an error.
I can just just the line COPY to filename DELIMITED WITH TAB but this creates the file for me with " around the fields which wont upload into sap for me. I know I can write a procedure to get rid of "" but I was hoping there might be a quicker solution.
Any ideas

Aiden
 
to explain: COPY TO textfile uses two delimiters: Field delimiter and string delimiter.

If Dave's suggestion won't work try

COPY TO somefile.txt DELIMITED WITH TAB WITH CHARACTER ""

read the help carefully about DELIMITED WITH Delimieter and DELIMITED WITH CHARCTER, it's even irritating to me, what is for what.

Bye, Olaf.
 
The real problem is that Help uses the term "delimiter" for two different things: delimiters and separators.

Delimiters go around things and they come in pairs. So, in this sentence, the word "junk" is delimited with double-quotes.

Separators separate things. The following list is separated by commas:

red,blue,green

In COPY TO, whatever you specify after DELIMITED WITH is the separator. What you specify with DELIMITED WITH CHARACTER is the delimiter.

Tamar
 
Aiden,

I'm not sure I agree.

The COPY TO ... DELIMITED that Dave and Olaf suggested may well give you what you want, but it definitely won't be an SDF file.

The whole point of SDF is that there are no delimiters. The fieds are determined by their position within the line. A file can't be both delimited and SDF.

Maybe you mean you want SDF, but with tabs used to pad out the fields (rather than spaces). In that case, the answer would depend on how many spaces constitute a tab (in other words, where do you place the "tab stops").

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
>> Just a quick question that I am hoping someone might have the answer to. I am outputting a file to sdf format but I also need it to be tab delimited ie
COPY TO filename TYPE SDF, works fine but if I add the DELIMITED WITH TAB it causes an error.

I agree with Mike. What you are asking does not make sense.

The point is that files are either "delimited" (where a columns are of variable length and a specific character is interepreted as defining the start of the next column) or "fixed width" (in which case the number of characters are counted to determine where a new column begins).

Importing text files into mainframe systems always uses one, or the other, method. They cannot be mixed. So either you have to use a delimiter, or you don't.

I do a lot of this stuff and we use both types of file delimited - usually with a "|" or a "~" and fixed width ( where we have to insert "filler" columns in our relational data to match the mapping on the mainframe 'flat-file' side)


----
Andy Kramek
Visual FoxPro MVP
 
Mike, I agree,

I didn't read carefully enough

SDF is a file type which pads fields according to their length, so there are no seperators at all and to import such a file you need a matching cursor with the expected field lengths.

SDF can't be combined, neither witha a seperator (DELIMITED WITH) nor a delimiter (WITH CHARACTER).

It also seems you can't define both seperator and delimiter, ie COPY TO "some.txt" TYPE DELIMITED WITH TAB WITH CHARACTER ';' gives syntax error.

Thanks Tamar for enlighting me about what is what. I think I'll remember that from now on.

Bye, Olaf.
 
Guys,
Thanks for the above I have been out on site since and havent had a chance to check back. I have to apologize first of all, The other person I am dealing with for the spec had in the email as sdf and tab delimited this was an error, it should have only been tab delimited.
I have since corrected the code and just like to thank you all for the above as I should have spoted it myself, it was only after reading your messages that the light bulb switched on ( I must be too close to my holidays)
Thanks again

Aiden
 
I read in the help that you could copy to a delimited file using with blank and with tab. I would like to copy out a tab delimited file but with blank instead of "" around the tab. Is that possible? I get only errors when I try to accomplish it.
Thanks in advance for your help.
Maxanne
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top