
Originally Posted by
schoolboy
There are several techniques for splitting a text string. And these are techniques used NOT in zencart, but in MS Office.
In MS Excel, you can split a text string using either FUNCTIONS or by the selection of a COMMON DELIMITER.
The FUNCTIONS method is detailed and relatively complex and involves using Excel formulae for SEARCH, LEN, and a few others.
The DELIMITER method will split a string where you define the delimiter as a common character in the column of text. For example, if your supplier splits each character with a / (slash), then you will use the slash as your field delimiter, and each string either side of the slash will be split into the appropriate number of adjacent cells.
so...
| category/sub-category/sub-sub-category | in a string, would be split into three adjacent cells, if you were to indicate that the text is delimited by the slash. The resul will be:
|category | sub-category | sub-sub-category |
We also use MSWord to split these sorts of things, we COPY the Excel column where all the text is joined, PASTE it into MSWord, and then:
1. use Convert Table to Text function
2. use Search and Replace function to FIND the common delimiter (let's say the slash) and to REPLACE it with a TAB CHARACTER. (In the REPLACE field you type ^t.)
Then, when the SLASHES have been replaced by TABS, we then reverse the TABLE to TEXT, and turn TEXT back to TABLE, this time indicating that the delimiter is a TAB.
We then get the different bits into separate TABLE COLUMNS.
We then COPY this table, and PASTE it back into the spreadsheet, making sure to align the pasted cells with the original cell, so that all data is in the correct ROWS.
We have successfully split co-joined text strings of over 10,000 product lines in under 5 minutes using these techniques.
So, go learn Excel and MSWord, and make them do the work!