Page 1 of 1

Convert fields in CSV to multiple rows retaining first colum

Posted: Tue Aug 07, 2007 11:22 pm
by Moz
Hi,

I have data like this:

43,12,13,27,31,54,76
44,43,152,
46,
47,84,128,151,190

The first column is ID1 and the remainders are each ID2 values for that one ID1. I want to change the data so it's in the following format:
ID1,ID2

e.g. the example data above would be:
43,12
43,13
43,27
43,31
43,54
43,76
44,43
44,152
46,
47,84
47,128
47,151
47,190

Any ideas how I can do this?

Many thanks for any help,

Moz

Posted: Wed Aug 08, 2007 12:39 pm
by DataMystic Support
Easy - you need to capture the data to a global, and then repeat it on each line. Drop us an email and we can send you the filter.

Posted: Thu Aug 09, 2007 9:18 am
by DataMystic Support
Emal sent. Here is the filter:

Restrict to each line in turn
|
|--EasyPattern [[ linestart, capture( longest 1+ digits) ],] with [$1]
| | [ ] Match case
| | [ ] Whole words only
| | [ ] Case sensitive replace
| | [ ] Prompt on replace
| | [ ] Skip prompt if identical
| | [ ] First only
| | [ ] Extract matches
| | Maximum text buffer size 4096
| |
| |--Capture to variable @recid
| |
| +--Remove all
|
|--EasyPattern [,] with [\r\n]
| [ ] Match case
| [ ] Whole words only
| [ ] Case sensitive replace
| [ ] Prompt on replace
| [ ] Skip prompt if identical
| [ ] First only
| [ ] Extract matches
| Maximum text buffer size 4096
|
+--Add left margin [@recid,]