Converting Space delimited file to Tab delimited file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Converting Space delimited file to Tab delimited file
# 8  
Old 02-23-2009
Quote:
Originally Posted by jeevs81
I'm getting "t" as a delimiter rather than a tab
works just fine under Solaris:
Code:
tr ' ' '\t' < /path2file/myFile.txt

Are you sure you have spaces and nothing else?
do 'cat -vet myFile' and post the results within the BB Codes.
# 9  
Old 02-23-2009
I'm still getting "t" as delimiter

-bash-3.00$ cat -vet test.txt
1 2 3 4$
5 6 7 8$
a b c d$
e f g h$

-bash-3.00$ tr ' ' '\t' < test.txt
1t2t3t4
5t6t7t8
atbtctd
etftgth

Please help me.
# 10  
Old 02-23-2009
Hi,

Hope the below commands should work.

1.sed 's/t/\t/g' filename

2.cat filename | tr 't' '\t'

Thanks
va2206Smilie
# 11  
Old 02-23-2009
va2206,

I think you misunderstood, I have a single space delimited file which I want to convert to tab delimited file.

Thanks,
Rajeevan
# 12  
Old 02-23-2009
Hi,

Can you please confirm that where is single space in your file?

360200tFY10tFEB-LTFt500420t12t0
460213tFY09tFEB-LTFt500420t09t15000
460213tFY09tFEB-LTFt500420t10t15000
077426tFY10tFEB-LTFt550200t12t0
077426tFY11tFEB-LTFt550200t12t0
677120tFY09tFEB-LTFt550200t07t57
677120tFY09tFEB-LTFt550200t09t57.5
977120tFY09tFEB-LTFt550200t06t561.5
477717tFY10tFEB-LTFt550200t12t0
577000tFY09tFEB-LTFt550200t12t327
577050tFY09tFEB-LTFt550200t08t86

Because of this reason I considered "t" as a delimeter.

Thanks,
va2206Smilie
# 13  
Old 02-23-2009
Did the OP follow vgersh99's suggestion (cat -vet) and I just missed it? I don't see the post anywhere...
# 14  
Old 02-24-2009
Quote:
Originally Posted by va2206
Hi,

Can you please confirm that where is single space in your file?

360200tFY10tFEB-LTFt500420t12t0
460213tFY09tFEB-LTFt500420t09t15000
460213tFY09tFEB-LTFt500420t10t15000
077426tFY10tFEB-LTFt550200t12t0
077426tFY11tFEB-LTFt550200t12t0
677120tFY09tFEB-LTFt550200t07t57
677120tFY09tFEB-LTFt550200t09t57.5
977120tFY09tFEB-LTFt550200t06t561.5
477717tFY10tFEB-LTFt550200t12t0
577000tFY09tFEB-LTFt550200t12t327
577050tFY09tFEB-LTFt550200t08t86

Because of this reason I considered "t" as a delimeter.

Thanks,
va2206Smilie
Hi va2206,

"t" is not the delimiter of my source file. My source file is delimited with a single white space. I need to convert them into tab delimited file. Please help me

Thanks,
Rajeevan D
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Replace a column in tab delimited file with column in other tab delimited file,based on match

Hello Everyone.. I want to replace the retail col from FileI with cstp1 col from FileP if the strpno matches in both files FileP.txt ... (2 Replies)
Discussion started by: YogeshG
2 Replies

2. Shell Programming and Scripting

Help/Advise please for converting space delimited string variable to comma delimited with quote

Hi, I am wanting to create a script that will construct a SQL statement based on a a space delimited string that it read from a config file. Example of the SQL will be For example, it will read a string like "AAA BBB CCC" and assign to a variable named IN_STRING. I then concatenate... (2 Replies)
Discussion started by: newbie_01
2 Replies

3. Shell Programming and Scripting

Output file with <Tab> or <Space> Delimited

Input file: xyz,pqrs.lmno,NA,NA,NA,NA,NA,NA,NA abcd,pqrs.xyz,NA,NA,NA,NA,NA,NA,NA Expected Output: xyz pqrs.lmno NA NA NA NA NA NA NA abcd pqrs.xyz NA NA NA NA NA NA NA Command Tried so far: awk -F"," 'BEGIN{OFS=" ";} {print}' $File_Path/File_Name.csv Issue:... (5 Replies)
Discussion started by: TechGyaann
5 Replies

4. UNIX for Dummies Questions & Answers

Need to convert a pipe delimited text file to tab delimited

Hi, I have a rquirement in unix as below . I have a text file with me seperated by | symbol and i need to generate a excel file through unix commands/script so that each value will go to each column. ex: Input Text file: 1|A|apple 2|B|bottle excel file to be generated as output as... (9 Replies)
Discussion started by: raja kakitapall
9 Replies

5. Shell Programming and Scripting

How to convert space&tab delimited file to CSV?

Hello, I have a text file with space and tab (mixed) delimited file and need to convert into CSV. # cat test.txt /dev/rmt/tsmmt32 HP Ultrium 6-SCSI J3LZ 50:03:08:c0:02:72:c0:b5 F00272C0B5 0/0/6/1/1.145.17.255.0.0.0 /dev/rmt/c102t0d0BEST /dev/rmt/tsmmt37 ... (6 Replies)
Discussion started by: prvnrk
6 Replies

6. Shell Programming and Scripting

Converting varied space delimited file to Pipedemilited

Hi all, I have source file, data looks like 12345 abc def 01 / 001200 C 2000 12345 abc def 01 / 001200 C 2500 12345 abcd def 01 / 001200 C 3500 18945 xyz pqr 01 / 009900 D 4000 5000 2800 9900 Expected ouput... (3 Replies)
Discussion started by: srk409
3 Replies

7. Shell Programming and Scripting

How to make tab delimited file to space delimited?

Hi How to make tab delimited file to space delimited? in put file: ABC kgy jkh ghj ash kjl o/p file: ABC kgy jkh ghj ash kjl Use code tags, thanks. (1 Reply)
Discussion started by: jagdishrout
1 Replies

8. UNIX for Dummies Questions & Answers

Changing only the first space to a tab in a space delimited text file

Hi, I have a space delimited text file but I only want to change the first space to a tab and keep the rest of the spaces intact. How do I go about doing that? Thanks! (3 Replies)
Discussion started by: evelibertine
3 Replies

9. Shell Programming and Scripting

Help with converting Pipe delimited file to Tab Delimited

I have a file which was pipe delimited, I need to make it tab delimited. I tried with sed but no use cat file | sed 's/|//t/g' The above command substituted "/t" not tab in the place of pipe. Sample file: abc|123|2012-01-30|2012-04-28|xyz have to convert to: abc 123... (6 Replies)
Discussion started by: karumudi7
6 Replies

10. Shell Programming and Scripting

Converting Tab delimited file to Comma delimited file in Unix

Hi, Can anyone let me know on how to convert a Tab delimited file to Comma delimited file in Unix Thanks!! (22 Replies)
Discussion started by: charan81
22 Replies
Login or Register to Ask a Question