Need to convert a pipe delimited text file to tab delimited


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Need to convert a pipe delimited text file to tab delimited
# 8  
Old 04-06-2015
Quote:
Originally Posted by Don Cragun
Hi wisecracker.

You lost me. There is nothing in post #1 in this thread that talks about converting | characters to tabs. That is much more easily done by the simple command:
Code:
tr '|' '\t'

What was requested was a way to convert a text file into a Microsoft Excel spreadsheet (presumably .xls, .xlsx, .xlsm, .xlsb, or .xlx) format (all of which are proprietary Microsoft binary formats). I know that some versions of perl are able to do with when certain plugins are available, but converting a pipe symbol separated values file into a tab separated values file does not seem to make any progress towards the request stated in post #1 in this thread. Am I missing something?
In my defence:-
1) The title, "Need to convert a pipe delimited text file to tab delimited"
2) OPs post #1 output shows space delimited.
3) My post #3 first line "(there are much better methods)", your simple one liner is what I would have done except the code I wrote was purely to show it could be done!
4) As we HAD, at the time, no real inupt from the OP as to what the OP's requirements were then all we have to go with are his input and output and the reply was done longhand deliberately. I assumed he wanted a '.txt' extension for Excel.
5) I read post #1 as the OP wanting to convert pipe separation to tab separation, (as a .txt extension), but being unsure whether 'CR' was required or not so left it out. Excle can load comma and tab separated files as '.csv' or '.txt' IIRC .
# 9  
Old 04-06-2015
Hi wisecracker,
I readily agree that the thread title, the text in post #1, and the examples given in post #1 all conflict with each other. And, in post #7, raja kakitapall tells us that the text or cvs or xls file is to be created by an unnamed database, and magically get excel to format that data for display in a mail message without invoking excel and without telling us what mail reader will be used to display the created xls file. But, I would never suggest writing a file one byte at a time using non-standard extensions to POSIX shell parameter expansions without knowing what operating system and shell the user is using. (And, even if I did know what shell they are using, I'd still use tr (or, if they also wanted to convert <newline> to <carriage-return><newline> for a Windows formatted file; sed).

It still isn't at all clear to me whether the OP wants to include a formatted table in the mail message (which has nothing to do with excel), or if the OP wants to attach an xls formatted file to be opened by the person receiving the mail using excel (which, as we have both already said could be done with the current text file format or with a text file using a comma or a tab as the field separator if the file's named ended with .csv).

Without a much clearer description of the actual environment, constraints, and desired output; I think we're stuck wasting time trying to guess at what might satisfy the OP.
# 10  
Old 04-06-2015
If you have an SQL query, why don't you modify that in the first place so it outputs its data in a structure that can be immediately interpreted by EXCEL (e.g. set colsep ";")
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert pipe demilited file to vertical tab delimited

Hi All, How can we convert pipe delimited ( or comma ) file to vertical tab (VT) delimited. Regards PK (4 Replies)
Discussion started by: prasson_ibm
4 Replies

2. UNIX for Beginners Questions & Answers

Convert Excel File (xls) to tab delimited text file on AIX

Hi i have a problem in my job i try to convert an excel file (xls extention) to text file (tab delimited), but no result with this comand cat xxx.xls > xxx.txt Do you have eny idea? PS: sorry for my english Thanks!! (4 Replies)
Discussion started by: frisso
4 Replies

3. Shell Programming and Scripting

Convert a 3 column tab delimited file to a matrix

Hi all, I have a 3 columns input file like this: CPLX9PC-4943 CPLX9PC-4943 1 CPLX9PC-4943 CpxID123 0 CPLX9PC-4943 CpxID126 0 CPLX9PC-4943 CPLX9PC-5763 0.5 CPLX9PC-4943 CpxID13 0 CPLX9PC-4943 CPLX9PC-6163 0 CPLX9PC-4943 CPLX9PC-6164 0.04... (7 Replies)
Discussion started by: AshwaniSharma09
7 Replies

4. 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

5. Shell Programming and Scripting

how to convert comma delimited file to tab separator

Hi all, How can i convert comma delimited .csv file to tab separate using sed command or script. Thanks, Krupa (4 Replies)
Discussion started by: krupasindhu18
4 Replies

6. 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

7. Shell Programming and Scripting

How to convert a space delimited file into a pipe delimited file using shellscript?

Hi All, I have space delimited file similar to the one as shown below.. I need to convert it as a pipe delimited, the values inside the pipe delimited file should be as highlighted... AA ATIU2345098809 009697 005374 BB ATIU2345097809 005445 006518 CC ATIU9685098809 003215 003571 DD... (7 Replies)
Discussion started by: nithins007
7 Replies

8. UNIX for Dummies Questions & Answers

How to convert a text file into tab delimited format?

I have a text file that made using text editor in Ubuntu. However the text file is not being recognized as space or tab delimited, the formatting seems to be messed up. How can I convert the text file into tab delimited format? (3 Replies)
Discussion started by: evelibertine
3 Replies

9. UNIX for Dummies Questions & Answers

How to convert text to columns in tab delimited text file

Hello Gurus, I have a text file containing nearly 12,000 tab delimited characters with 4000 rows. If the file size is small, excel can convert the text into coloumns. However, the file that I have is very big. Can some body help me in solving this problem? The input file example, ... (6 Replies)
Discussion started by: Unilearn
6 Replies

10. Shell Programming and Scripting

convert a pipe delimited file to a':" delimited file

i have a file whose data is like this:: osr_pe_assign|-120|wg000d@att.com|4| osr_evt|-21|wg000d@att.com|4| pe_avail|-21|wg000d@att.com|4| osr_svt|-11|wg000d@att.com|4| pe_mop|-13|wg000d@att.com|4| instar_ready|-35|wg000d@att.com|4| nsdnet_ready|-90|wg000d@att.com|4|... (6 Replies)
Discussion started by: priyanka3006
6 Replies
Login or Register to Ask a Question