Advertisement

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

Convert tabs to spaces in tcl??

Tags:

tcl, 8.4

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?
 
 
 
Expert Comment by fridom:

All comments and solutions are available to Premium Service Members only. Start your 7-day free trial to view the solution to this question.

Already a member? Login to view this solution.

 
 
Expert Comment by leh327:

All comments and solutions are available to Premium Service Members only. Start your 7-day free trial to view the solution to this question.

Already a member? Login to view this solution.

 
 
Author Comment by sjmont:

All comments and solutions are available to Premium Service Members only. Start your 7-day free trial to view the solution to this question.

Already a member? Login to view this solution.

 
 
Expert Comment by leh327:

All comments and solutions are available to Premium Service Members only. Start your 7-day free trial to view the solution to this question.

Already a member? Login to view this solution.

 
 
Expert Comment by leh327:

All comments and solutions are available to Premium Service Members only. Start your 7-day free trial to view the solution to this question.

Already a member? Login to view this solution.

 
 
20081119-EE-VQP-45 - Hierarchy / EE_QW_2_20070628