add field and append 2 fields into new added field; reformat

Get help with installation and running here.

Moderators: DataMystic Support, Moderators, DataMystic Support, Moderators, DataMystic Support, Moderators

Post Reply
john
Posts: 1
Joined: Thu Jul 21, 2005 5:02 pm

add field and append 2 fields into new added field; reformat

Post by john »

Example: csv file with a header

"name","addr1","filler","addr2","city"
"john","123 main st","-","apt 1024","pensacola"


Would like new output to look like
"name","address","city"
"john","123 main st apt 1024","pensacola"


I would like to process the csv file with header taking addr1 and addr2 merging them into a new field called street then remove the addr1, filler and addr2 fields.

Thanks for the help
User avatar
DataMystic Support
Site Admin
Posts: 2227
Joined: Mon Jun 30, 2003 12:32 pm
Location: Melbourne, Australia
Contact:

Post by DataMystic Support »

Use an EasyPattern along these lines:

[ capture( csvfield ), ',',
capture( csvfield ), ',',
capture( csvfield ), ',',
capture( csvfield ), ',',
capture( csvfield ), cr, lf,
capture( csvfield ), ',',
capture( csvfield ), ',',
capture( csvfield ), ',',
capture( csvfield ), ',',
capture( csvfield ), cr, lf ]

Replace with

$1,$2,$3 etc in the order you need.
Post Reply