Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm going to clarify this a bit. If you have a user formatted file that has a predictable format (ie the user has generated the data out of EXCEL or similar program) then you are way better off using an exising parser that is well tested.</p> <p>Scenarios like the following are just a few examples that manual parsing will have problems with:</p> <pre><code>"column 1", 2, 0104400, $1,300, "This is an interestion question, he said" </code></pre> <p>.. and there are more with escaping, file formats etc that can be a headache for roll your own.</p> <p>If you do that, then ensure you get one that can tollerate differences in columns per row as it can make a difference.</p> <p>If, on the other hand, you know what's going into the data which is common in system generated files then using CSV parsers will cause more problems than they solve. For example, I have dealt with scenarios where the first part is fixed and can be strongly typed, but there are following parts in a row that are not. This can also happen if you're parsing flat file data in fixed width scenarios from legacy databases. A csv solution makes assumptions we don't want and is not the right solution in many of those cases.</p> <p>If that is the case and you just want to strip out quotes after splitting on commas, then try a bit of linq. This can also be extended to replace specific characters you are worried about.</p> <pre><code>line.Split(',').Select(i =&gt; i.Replace("\"", "")).ToArray() </code></pre> <p>Hope that clears up all the conflicting advice.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload