tab delimited file that is not tab delimited. | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

tab delimited file that is not tab delimited.

UNIX for Dummies Questions & Answers


Tags
not read correctly, tab delimited

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-23-2012
imlearning imlearning is offline
Registered User
 
Join Date: Jan 2012
Last Activity: 23 January 2012, 10:47 PM EST
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
tab delimited file that is not tab delimited.

Hi Forum
I have a tab delimited file that opens well in Openoffice calc (excel). But when I perform any operation in command line, it reads the file incorrectly. When I 'save As' the same file in office as tab delimited then it works fine.

The file that I think is tab delimited is actually not the same according to unix/linux bash/sh script.

What may be the reason. My dummy guess is that there may be embedded space in between.

Which command do I use to make this file unix compatible tab delimted file.
Thanks
Sponsored Links
    #2  
Old 01-23-2012
bartus11's Avatar
bartus11 bartus11 is offline Forum Staff  
Moderator
 
Join Date: Apr 2009
Last Activity: 12 September 2014, 1:32 PM EDT
Posts: 3,710
Thanks: 7
Thanked 1,142 Times in 1,113 Posts
Post output of:
Code:
cat -Te your.file | head

Sponsored Links
    #3  
Old 01-23-2012
imlearning imlearning is offline
Registered User
 
Join Date: Jan 2012
Last Activity: 23 January 2012, 10:47 PM EST
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by bartus11 View Post
Post output of:
Code:
cat -Te your.file | head


Code:
$ cat -Te  1327.txt | head
country^Iyear^IQty^M$
Japan^I961^I303^M$
Japan^I996^I5021^M$
Japan^I608^I2633^M$
USA^I620^I645^M$
USA^I437^I62^M$
Japan^I565^I90^M$
UK^I705^I730^M$
Japan^I5794^I819^M$
Japan^I890^I5915^M$

    #4  
Old 01-23-2012
imlearning imlearning is offline
Registered User
 
Join Date: Jan 2012
Last Activity: 23 January 2012, 10:47 PM EST
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by bartus11 View Post
Post output of:
Code:
cat -Te your.file | head


Code:
$ cat -Te  1327.txt | head
country^Iyear^IQty^M$
Japan^I961^I303^M$
Japan^I996^I5021^M$
Japan^I608^I2633^M$
USA^I620^I645^M$
USA^I437^I62^M$
Japan^I565^I90^M$
UK^I705^I730^M$
Japan^I5794^I819^M$
Japan^I890^I5915^M$

Sponsored Links
    #5  
Old 01-23-2012
frank_rizzo frank_rizzo is offline Forum Advisor  
Resident BOFH
 
Join Date: Dec 2007
Last Activity: 21 August 2014, 4:30 PM EDT
Posts: 1,136
Thanks: 2
Thanked 88 Times in 85 Posts
looks like the file is using windows line endings. can you save as ascii? try converting the file to ascii.
Sponsored Links
    #6  
Old 01-23-2012
bartus11's Avatar
bartus11 bartus11 is offline Forum Staff  
Moderator
 
Join Date: Apr 2009
Last Activity: 12 September 2014, 1:32 PM EDT
Posts: 3,710
Thanks: 7
Thanked 1,142 Times in 1,113 Posts
You can use "dos2unix" tool to convert Windows style newlines to Unix:
Code:
dos2unix 1327.txt > 1327-converted.txt

Try running your command line tools/scripts on the resulting file.
Sponsored Links
    #7  
Old 01-23-2012
imlearning imlearning is offline
Registered User
 
Join Date: Jan 2012
Last Activity: 23 January 2012, 10:47 PM EST
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
I am working in linux and has nothing to do with windows. I used to generate these files using php. Is the php code culprit for this? I opened the same file in gedit and changed the saving parameter "line ending" from "Windows" to "unix" and worked.
Frank_rizzo and bartus11, thanks.
Is there a way to determine if it is windows file and if it is so then apply some method to convert it as I have large number of files.

Thanks

Last edited by imlearning; 01-23-2012 at 07:31 PM..
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to convert a space delimited file into a pipe delimited file using shellscript? nithins007 Shell Programming and Scripting 7 09-25-2011 05:33 AM
awk help - delimited file ashwin3086 Shell Programming and Scripting 8 10-30-2010 12:42 PM
convert a pipe delimited file to a':" delimited file priyanka3006 Shell Programming and Scripting 6 05-26-2009 10:53 AM
Converting Space delimited file to Tab delimited file jeevs81 UNIX for Dummies Questions & Answers 16 02-26-2009 01:49 AM
Converting Tab delimited file to Comma delimited file in Unix charan81 Shell Programming and Scripting 22 01-20-2006 08:24 AM



All times are GMT -4. The time now is 07:49 AM.