I've tried many different approaches but obviously not the right one. Any Ideas? Thanks PS Single quotes in the replace function cause a complier error. I think it is not a good idea to do a simple split by coma. If for example a text field has a coma in the middle? Also simple removing quotas is not a best solution because if the field has a quota then in CSV file it will be doubbled - you've got to remove doubles as well.
You can say It is not your case - well it is about design quality. I would suggest to process the string as character by character. HTH Slav. You can try to parse it with the FileHelpers library. Ask a question. Quick access. Search related threads. The construction? That is important since I need to use that comma in the next match. The way I understand this is that there is a variable called "output. The quotes will not be included in my replace statement above if this pattern is matched because they are outside of the "output" parentheses.
This is what is assigned to the "output" capture variable if the pattern is matched. Note that the whole pattern, including the surrounding double quotes, is in the "output" capture and thus will be output by the replace statement. It will stop if it finds a double quote followed by the comma or end of string. I want to leave them alone. If there are an even number of double quotes before the comma then continue looking for the end of the column.
What I am trying to avoid is interpreting exactly two or any even number of double quotes preceding a comma being interpreted as the end of the match. If there are two quotes, then treat the comma as part of the current column. If there is one quote, then treat the comma as the break between two columns. Basically, if there are an even number of double quotes before a comma then treat that comma as part of the current column and continue looking for the next sequence of double quotes followed by comma to end the column.
You must log in to post a comment. Loski's SQL Movements. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Stack Gives Back Safety in numbers: crowdsourcing data on nefarious IP addresses. Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually.
Related Hot Network Questions. Question feed. Stack Overflow works best with JavaScript enabled. Accept all cookies Customize settings.
0コメント