How to handle delimiter(,) in csv
Hi I need to transfer data(product details) from one online store to another. So I have exported data from source store in .CSV format. Now I want to create target store compatible .CSV to import to the target store. There are field like: "ProductCode,ProductName,ProductDescription" and so on. So in ProductDescription column if there is comma(,) present in ProductDescription so it goes to the next column from the comma(,). So please tell me that how can I bind whole description as one record for that particular product??
VulpesPosted Apr 24, 2012, 6:11 AM
However, one technique you can use is to:
1. Temporarily replace any commas which are embedded in quoted fields by a special character.
2. Remove all the quotes.
3. Split each line using the remaining commas as delimiters.
4. Iterate through the resulting fields and replace the special character with a comma again.
The special character needs to be chosen to be something that you're certain won't appear in the file naturally. One I often use is code point 255.
Here's some example code showing how this technique can be applied to a single line which contains embedded commas:
The output should be:
rucha joshiPosted Apr 24, 2012, 5:14 AM
Poppa WallacePosted Apr 24, 2012, 5:11 AM
Check it out
http://filehelpers.sourceforge.net/
Good Lcuk
Jay
VulpesPosted Apr 24, 2012, 5:04 AM