Converting CSV to tab delimited with TP
Posted: Mon Sep 15, 2014 10:49 pm
I'm using TP to convert a CSV (Comma Separated Values) file to a tab delimited file.
I first performed this RE Replace until no more lines were changed.
Find what: "([^,"\r\n]+),([^"\r\n]+)"
Replace with: "$1\xFF$2"
This was to convert commas delimited between double quotes (") to \xFF (ÿ), which was not in the file.
Then this RE Replace.
Find what: ,
Replace with: \t
This was to convert commas which are true delimiters to \t (tab).
Finally this RE Replace.
Find what: \xFF
Replace with: ,
This was to convert commas within double quote delimiters back to commas.
I suppose Excel 2010 could do this, but it's an almost 900 MB file and I tend not to trust tools that convert stuff and "help me" when I want to see the really, real bytes. Hence, I use TP for such tasks.
I first performed this RE Replace until no more lines were changed.
Find what: "([^,"\r\n]+),([^"\r\n]+)"
Replace with: "$1\xFF$2"
This was to convert commas delimited between double quotes (") to \xFF (ÿ), which was not in the file.
Then this RE Replace.
Find what: ,
Replace with: \t
This was to convert commas which are true delimiters to \t (tab).
Finally this RE Replace.
Find what: \xFF
Replace with: ,
This was to convert commas within double quote delimiters back to commas.
I suppose Excel 2010 could do this, but it's an almost 900 MB file and I tend not to trust tools that convert stuff and "help me" when I want to see the really, real bytes. Hence, I use TP for such tasks.