Advertisement

11.11.2008 at 10:27AM PST, ID: 23895453 | Points: 500
[x]
Attachment Details

Convert tabs to spaces in tcl??

Asked by sjmont in TCL Scripting Language, KornShell (ksh)

Tags: ,

Using tcl, I'm reading through a file generated by a report-writer. There are some records that have tabs in them, some don't. I need to parse out the fields (columns in the report) positionally. The problem is using string range or crange views the \t in the records as single characters

I tried doing
regsub -all $rec \t "     " rec
but since the amount of whitespace in a tab is not static, I was getting undesired results.

Example of report line:
10/27/08                   801062347       801062347                .00    Charge                  70.99       N
Corresponding example of octal display from the report file:
0001460   \r  \n   1   0   /   2   7   /   0   8                  \t  \t
0001500                8   0   1   0   6   2   3   4   7  \t
0001520    8   0   1   0   6   2   3   4   7  \t  \t                   .
0001540    0   0                   C   h   a   r   g   e  \t  \t
0001560        7   0   .   9   9                               N  \r  \n

I'd prefer to handle this in the tcl script but if necessary, I suppose I can manipulate the file using ksh beforehand, although I'm not sure how I would do that either.

Any ideas?Start Free Trial
[+][-]11.12.2008 at 05:20AM PST, ID: 22939148

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.07.2009 at 07:27AM PST, ID: 23315587

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.07.2009 at 08:25AM PST, ID: 23316435

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.07.2009 at 09:17AM PST, ID: 23316960

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.07.2009 at 10:31AM PST, ID: 23317778

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 - Hierarchy / EE_QW_2_20070628