my task is to import CSV files into SQL tables. The issue comes up when parsing each line within the file. The file is COMMA DELIMITED. Which is easy to handle, but texts are in quotes.
For example:
2, 2012-02-14, "David", "David does, not, show up ", "AS", 22
Here is how I am handling/parsing this:
string query = "Insert into " + SchemaName + ".[" + TableName + "] (" + ColumnList + ") ";
query += "VALUES('" + line.Replace(FileDelimiter, "','") + "')";
This works very well, of course with two issues:
Whenever there is comma in my text field, you get a new column/field, which is inaccurate and throws an error. In above, we have: "David does" - "not" "show up" as three columns, but it's really just one.
I end up importing quotes. So my columns have things like: "AS" instead of just AS
Is there anything in SSIS/C# I can use to just parse the line? How can I over come the text qualifiers?
I tried using the Replace function. But that doesn't work. This is all done within C# sctript task in SSIS.
Note, I've already read the forum here - that only highlights the issue and no answer. The accepted answer provides dead links to "petitions". No real answer is there.