Exporting/Saving a TAB Delimited .txt file

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Exporting/Saving a TAB Delimited .txt file

Heidi Green

Hello-

I am attempting to export or Save Translate an SPSS 17 data set into a Tab delimited .txt file. I am currently using this syntax:

 

SAVE TRANSLATE OUTFILE='MyFileName.txt'

  /TYPE=TAB

  /MAP

  /REPLACE

  /FIELDNAMES

  /CELLS=VALUES.

 

The problem that I am having is that the last column of my data (a STRING field) is blank for some records. When exporting/saving, it appears that the program is putting a space in this column for the records without data. I tried recoding the field AND left trimming it, but the spaces won’t go away.

 

RECODE Var1 ("     " = "").

COMPUTE Var1 LTRIM(Var1).

 

 

The goal is to remove the spaces for these records so that the line ends earlier for those rows (vary the ending row position).  I have been told that this is known as a ragged right file format, although my knowledge of .txt files is very limited.

 

Would using the WRITE OUTFILE command rather than SAVE TRANSLATE help this problem? If so, does anyone have an example of the syntax to do that AND specify TAB delimited? The only one I have used is: WRITE OUTFILE='MyFileName.txt'   TABLE /all.   I think this produces a Fixed Width file?

 

Thank you all in advance for any advice you can provide.

 

-Heidi Green

Reply | Threaded
Open this post in threaded view
|

Re: Exporting/Saving a TAB Delimited .txt file

Oliver, Richard

If the string is blank, tab format should only insert a single space for the string value. Why is that a problem? The WRITE command will not give you what you want. It will right-pad with blank spaces.

 


From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Heidi Green
Sent: Wednesday, February 25, 2009 1:58 PM
To: [hidden email]
Subject: Exporting/Saving a TAB Delimited .txt file

 

Hello-

I am attempting to export or Save Translate an SPSS 17 data set into a Tab delimited .txt file. I am currently using this syntax:

 

SAVE TRANSLATE OUTFILE='MyFileName.txt'

  /TYPE=TAB

  /MAP

  /REPLACE

  /FIELDNAMES

  /CELLS=VALUES.

 

The problem that I am having is that the last column of my data (a STRING field) is blank for some records. When exporting/saving, it appears that the program is putting a space in this column for the records without data. I tried recoding the field AND left trimming it, but the spaces won’t go away.

 

RECODE Var1 ("     " = "").

COMPUTE Var1 LTRIM(Var1).

 

 

The goal is to remove the spaces for these records so that the line ends earlier for those rows (vary the ending row position).  I have been told that this is known as a ragged right file format, although my knowledge of .txt files is very limited.

 

Would using the WRITE OUTFILE command rather than SAVE TRANSLATE help this problem? If so, does anyone have an example of the syntax to do that AND specify TAB delimited? The only one I have used is: WRITE OUTFILE='MyFileName.txt'   TABLE /all.   I think this produces a Fixed Width file?

 

Thank you all in advance for any advice you can provide.

 

-Heidi Green

Reply | Threaded
Open this post in threaded view
|

Re: Exporting/Saving a TAB Delimited .txt file

Heidi Green

Thank you for your response, Richard.

It is inserting a single space, like you mentioned.

Our fear is that the system our client needs to import the data into will hiccup on this fact; as the file they are currently receiving (from a SQL source, I believe), does not have the single space.

I can try to use Data Junction or some other program to strip them out, but I was hoping for a one-program (SPSS only) solution.

 


From: Oliver, Richard [mailto:[hidden email]]
Sent: Wednesday, February 25, 2009 12:23 PM
To: Heidi Green; [hidden email]
Subject: RE: Exporting/Saving a TAB Delimited .txt file

 

If the string is blank, tab format should only insert a single space for the string value. Why is that a problem? The WRITE command will not give you what you want. It will right-pad with blank spaces.

 


From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Heidi Green
Sent: Wednesday, February 25, 2009 1:58 PM
To: [hidden email]
Subject: Exporting/Saving a TAB Delimited .txt file

 

Hello-

I am attempting to export or Save Translate an SPSS 17 data set into a Tab delimited .txt file. I am currently using this syntax:

 

SAVE TRANSLATE OUTFILE='MyFileName.txt'

  /TYPE=TAB

  /MAP

  /REPLACE

  /FIELDNAMES

  /CELLS=VALUES.

 

The problem that I am having is that the last column of my data (a STRING field) is blank for some records. When exporting/saving, it appears that the program is putting a space in this column for the records without data. I tried recoding the field AND left trimming it, but the spaces won’t go away.

 

RECODE Var1 ("     " = "").

COMPUTE Var1 LTRIM(Var1).

 

 

The goal is to remove the spaces for these records so that the line ends earlier for those rows (vary the ending row position).  I have been told that this is known as a ragged right file format, although my knowledge of .txt files is very limited.

 

Would using the WRITE OUTFILE command rather than SAVE TRANSLATE help this problem? If so, does anyone have an example of the syntax to do that AND specify TAB delimited? The only one I have used is: WRITE OUTFILE='MyFileName.txt'   TABLE /all.   I think this produces a Fixed Width file?

 

Thank you all in advance for any advice you can provide.

 

-Heidi Green



____________
DefenderMX4.
Reply | Threaded
Open this post in threaded view
|

Re: Exporting/Saving a TAB Delimited .txt file

Mark Casazza-2
Heidi,

Just to verify, is it truly a space hex value of '20' or a tab hex value of '09'?  Both would probably appear as a "space" in a regular text editor.  That said, most database applications should treat a non-printing character all by itself in a field as a null--Oracle and mySQL would, but I don't have any real-world experience with others so I'm  making an educated guess :)

I'd suggest opening the file in a hex editor to see what's really there.

Mark

"On the other hand, if you think the problem is bad now, just wait until we've fixed it."
- ColdWetDog - commenting on privacy and electronic health records on /. 2009-01-18


Mark Casazza
Director of Academic Information
The City University of New York
555 West 57th Street, Suite 1240
New York, NY 10019

Phone: 212.541.0396
Fax: 212.541.0392


Heidi Green wrote:

Thank you for your response, Richard.

It is inserting a single space, like you mentioned.

Our fear is that the system our client needs to import the data into will hiccup on this fact; as the file they are currently receiving (from a SQL source, I believe), does not have the single space.

I can try to use Data Junction or some other program to strip them out, but I was hoping for a one-program (SPSS only) solution.

 


From: Oliver, Richard [[hidden email]]
Sent: Wednesday, February 25, 2009 12:23 PM
To: Heidi Green; [hidden email]
Subject: RE: Exporting/Saving a TAB Delimited .txt file

 

If the string is blank, tab format should only insert a single space for the string value. Why is that a problem? The WRITE command will not give you what you want. It will right-pad with blank spaces.

 


From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Heidi Green
Sent: Wednesday, February 25, 2009 1:58 PM
To: [hidden email]
Subject: Exporting/Saving a TAB Delimited .txt file

 

Hello-

I am attempting to export or Save Translate an SPSS 17 data set into a Tab delimited .txt file. I am currently using this syntax:

 

SAVE TRANSLATE OUTFILE='MyFileName.txt'

  /TYPE=TAB

  /MAP

  /REPLACE

  /FIELDNAMES

  /CELLS=VALUES.

 

The problem that I am having is that the last column of my data (a STRING field) is blank for some records. When exporting/saving, it appears that the program is putting a space in this column for the records without data. I tried recoding the field AND left trimming it, but the spaces won’t go away.

 

RECODE Var1 ("     " = "").

COMPUTE Var1 LTRIM(Var1).

 

 

The goal is to remove the spaces for these records so that the line ends earlier for those rows (vary the ending row position).  I have been told that this is known as a ragged right file format, although my knowledge of .txt files is very limited.

 

Would using the WRITE OUTFILE command rather than SAVE TRANSLATE help this problem? If so, does anyone have an example of the syntax to do that AND specify TAB delimited? The only one I have used is: WRITE OUTFILE='MyFileName.txt'   TABLE /all.   I think this produces a Fixed Width file?

 

Thank you all in advance for any advice you can provide.

 

-Heidi Green



____________
DefenderMX4.
===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Exporting/Saving a TAB Delimited .txt file

Heidi Green

Yes, it is a hex ‘20’ (space).

 


From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Mark Casazza
Sent: Wednesday, February 25, 2009 1:02 PM
To: [hidden email]
Subject: Re: Exporting/Saving a TAB Delimited .txt file

 

Heidi,

Just to verify, is it truly a space hex value of '20' or a tab hex value of '09'?  Both would probably appear as a "space" in a regular text editor.  That said, most database applications should treat a non-printing character all by itself in a field as a null--Oracle and mySQL would, but I don't have any real-world experience with others so I'm  making an educated guess :)

I'd suggest opening the file in a hex editor to see what's really there.

Mark

"On the other hand, if you think the problem is bad now, just wait until we've fixed it."
- ColdWetDog - commenting on privacy and electronic health records on /. 2009-01-18


Mark Casazza
Director of Academic Information
The City University of New York
555 West 57th Street, Suite 1240
New York, NY 10019

Phone: 212.541.0396
Fax: 212.541.0392



Heidi Green wrote:

Thank you for your response, Richard.

It is inserting a single space, like you mentioned.

Our fear is that the system our client needs to import the data into will hiccup on this fact; as the file they are currently receiving (from a SQL source, I believe), does not have the single space.

I can try to use Data Junction or some other program to strip them out, but I was hoping for a one-program (SPSS only) solution.

 


From: Oliver, Richard [[hidden email]]
Sent: Wednesday, February 25, 2009 12:23 PM
To: Heidi Green; [hidden email]
Subject: RE: Exporting/Saving a TAB Delimited .txt file

 

If the string is blank, tab format should only insert a single space for the string value. Why is that a problem? The WRITE command will not give you what you want. It will right-pad with blank spaces.

 


From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Heidi Green
Sent: Wednesday, February 25, 2009 1:58 PM
To: [hidden email]
Subject: Exporting/Saving a TAB Delimited .txt file

 

Hello-

I am attempting to export or Save Translate an SPSS 17 data set into a Tab delimited .txt file. I am currently using this syntax:

 

SAVE TRANSLATE OUTFILE='MyFileName.txt'

  /TYPE=TAB

  /MAP

  /REPLACE

  /FIELDNAMES

  /CELLS=VALUES.

 

The problem that I am having is that the last column of my data (a STRING field) is blank for some records. When exporting/saving, it appears that the program is putting a space in this column for the records without data. I tried recoding the field AND left trimming it, but the spaces won’t go away.

 

RECODE Var1 ("     " = "").

COMPUTE Var1 LTRIM(Var1).

 

 

The goal is to remove the spaces for these records so that the line ends earlier for those rows (vary the ending row position).  I have been told that this is known as a ragged right file format, although my knowledge of .txt files is very limited.

 

Would using the WRITE OUTFILE command rather than SAVE TRANSLATE help this problem? If so, does anyone have an example of the syntax to do that AND specify TAB delimited? The only one I have used is: WRITE OUTFILE='MyFileName.txt'   TABLE /all.   I think this produces a Fixed Width file?

 

Thank you all in advance for any advice you can provide.

 

-Heidi Green



____________
DefenderMX4.



____________
DefenderMX4. ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Exporting/Saving a TAB Delimited .txt file

ViAnn Beadle

I have to say that I find it strange that some program will “hiccup” on a trailing space in a text file. How about putting in something else by recoding the blank to a particular value?

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Heidi Green
Sent: Wednesday, February 25, 2009 2:10 PM
To: [hidden email]
Subject: Re: Exporting/Saving a TAB Delimited .txt file

 

Yes, it is a hex ‘20’ (space).

 


From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Mark Casazza
Sent: Wednesday, February 25, 2009 1:02 PM
To: [hidden email]
Subject: Re: Exporting/Saving a TAB Delimited .txt file

 

Heidi,

Just to verify, is it truly a space hex value of '20' or a tab hex value of '09'?  Both would probably appear as a "space" in a regular text editor.  That said, most database applications should treat a non-printing character all by itself in a field as a null--Oracle and mySQL would, but I don't have any real-world experience with others so I'm  making an educated guess :)

I'd suggest opening the file in a hex editor to see what's really there.

Mark

"On the other hand, if you think the problem is bad now, just wait until we've fixed it."
- ColdWetDog - commenting on privacy and electronic health records on /. 2009-01-18


Mark Casazza
Director of Academic Information
The City University of New York
555 West 57th Street, Suite 1240
New York, NY 10019

Phone: 212.541.0396
Fax: 212.541.0392



Heidi Green wrote:

Thank you for your response, Richard.

It is inserting a single space, like you mentioned.

Our fear is that the system our client needs to import the data into will hiccup on this fact; as the file they are currently receiving (from a SQL source, I believe), does not have the single space.

I can try to use Data Junction or some other program to strip them out, but I was hoping for a one-program (SPSS only) solution.

 


From: Oliver, Richard [[hidden email]]
Sent: Wednesday, February 25, 2009 12:23 PM
To: Heidi Green; [hidden email]
Subject: RE: Exporting/Saving a TAB Delimited .txt file

 

If the string is blank, tab format should only insert a single space for the string value. Why is that a problem? The WRITE command will not give you what you want. It will right-pad with blank spaces.

 


From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Heidi Green
Sent: Wednesday, February 25, 2009 1:58 PM
To: [hidden email]
Subject: Exporting/Saving a TAB Delimited .txt file

 

Hello-

I am attempting to export or Save Translate an SPSS 17 data set into a Tab delimited .txt file. I am currently using this syntax:

 

SAVE TRANSLATE OUTFILE='MyFileName.txt'

  /TYPE=TAB

  /MAP

  /REPLACE

  /FIELDNAMES

  /CELLS=VALUES.

 

The problem that I am having is that the last column of my data (a STRING field) is blank for some records. When exporting/saving, it appears that the program is putting a space in this column for the records without data. I tried recoding the field AND left trimming it, but the spaces won’t go away.

 

RECODE Var1 ("     " = "").

COMPUTE Var1 LTRIM(Var1).

 

 

The goal is to remove the spaces for these records so that the line ends earlier for those rows (vary the ending row position).  I have been told that this is known as a ragged right file format, although my knowledge of .txt files is very limited.

 

Would using the WRITE OUTFILE command rather than SAVE TRANSLATE help this problem? If so, does anyone have an example of the syntax to do that AND specify TAB delimited? The only one I have used is: WRITE OUTFILE='MyFileName.txt'   TABLE /all.   I think this produces a Fixed Width file?

 

Thank you all in advance for any advice you can provide.

 

-Heidi Green



____________
DefenderMX4.



____________
DefenderMX4.

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD

Reply | Threaded
Open this post in threaded view
|

Re: Exporting/Saving a TAB Delimited .txt file

Heidi Green

Thank you for your suggestion, ViAnn.

My first task was to try to reproduce exactly what the client previously received from another vendor. If that isn’t possible, then my next step will be to work with them to figure out a solution that will cause the least amount of changes on their part.

Thanks again,

-Heidi

 

 


From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of ViAnn Beadle
Sent: Wednesday, February 25, 2009 1:19 PM
To: [hidden email]
Subject: Re: Exporting/Saving a TAB Delimited .txt file

 

I have to say that I find it strange that some program will “hiccup” on a trailing space in a text file. How about putting in something else by recoding the blank to a particular value?

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Heidi Green
Sent: Wednesday, February 25, 2009 2:10 PM
To: [hidden email]
Subject: Re: Exporting/Saving a TAB Delimited .txt file

 

Yes, it is a hex ‘20’ (space).

 


From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Mark Casazza
Sent: Wednesday, February 25, 2009 1:02 PM
To: [hidden email]
Subject: Re: Exporting/Saving a TAB Delimited .txt file

 

Heidi,

Just to verify, is it truly a space hex value of '20' or a tab hex value of '09'?  Both would probably appear as a "space" in a regular text editor.  That said, most database applications should treat a non-printing character all by itself in a field as a null--Oracle and mySQL would, but I don't have any real-world experience with others so I'm  making an educated guess :)

I'd suggest opening the file in a hex editor to see what's really there.

Mark

"On the other hand, if you think the problem is bad now, just wait until we've fixed it."
- ColdWetDog - commenting on privacy and electronic health records on /. 2009-01-18


Mark Casazza
Director of Academic Information
The City University of New York
555 West 57th Street, Suite 1240
New York, NY 10019

Phone: 212.541.0396
Fax: 212.541.0392



Heidi Green wrote:

Thank you for your response, Richard.

It is inserting a single space, like you mentioned.

Our fear is that the system our client needs to import the data into will hiccup on this fact; as the file they are currently receiving (from a SQL source, I believe), does not have the single space.

I can try to use Data Junction or some other program to strip them out, but I was hoping for a one-program (SPSS only) solution.

 


From: Oliver, Richard [[hidden email]]
Sent: Wednesday, February 25, 2009 12:23 PM
To: Heidi Green; [hidden email]
Subject: RE: Exporting/Saving a TAB Delimited .txt file

 

If the string is blank, tab format should only insert a single space for the string value. Why is that a problem? The WRITE command will not give you what you want. It will right-pad with blank spaces.

 


From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Heidi Green
Sent: Wednesday, February 25, 2009 1:58 PM
To: [hidden email]
Subject: Exporting/Saving a TAB Delimited .txt file

 

Hello-

I am attempting to export or Save Translate an SPSS 17 data set into a Tab delimited .txt file. I am currently using this syntax:

 

SAVE TRANSLATE OUTFILE='MyFileName.txt'

  /TYPE=TAB

  /MAP

  /REPLACE

  /FIELDNAMES

  /CELLS=VALUES.

 

The problem that I am having is that the last column of my data (a STRING field) is blank for some records. When exporting/saving, it appears that the program is putting a space in this column for the records without data. I tried recoding the field AND left trimming it, but the spaces won’t go away.

 

RECODE Var1 ("     " = "").

COMPUTE Var1 LTRIM(Var1).

 

 

The goal is to remove the spaces for these records so that the line ends earlier for those rows (vary the ending row position).  I have been told that this is known as a ragged right file format, although my knowledge of .txt files is very limited.

 

Would using the WRITE OUTFILE command rather than SAVE TRANSLATE help this problem? If so, does anyone have an example of the syntax to do that AND specify TAB delimited? The only one I have used is: WRITE OUTFILE='MyFileName.txt'   TABLE /all.   I think this produces a Fixed Width file?

 

Thank you all in advance for any advice you can provide.

 

-Heidi Green



____________
DefenderMX4.



____________
DefenderMX4.

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD



____________
DefenderMX4.