Parse each line by character location

Shawn Milochik Shawn at milochik.com
Wed Nov 5 11:39:02 EST 2008


I work with tab-delimited files for a living. Because of the same need
you have, I created a Python script to do this. It has usage
information that is easy to follow (just run it without any
arguments).

I hope someone else finds this useful. I have, and use it every month.
It can be easily modified to create comma-delimited files, but that's
something I never use, so it does tabs.

http://milochik.com/shawn/fwconvert.zip



    Usage:
    	fwconvert -r rulesFile fileName [-t|-f]
    	or
    	cat filename | fwconvert -r rulesFile" (-t|-f)
    	
    	-t (to tab) or -f (to fixed-width) required when piping input to
script. Otherwise, it will be auto-determined.
    	

    	Rules file format:
    		fieldStart:fieldLength,fieldStart:fieldLength...
    		Example:
    			1:3,4:20,24:5



More information about the Python-list mailing list