I apologize for the length of the description.
I have a comma-delimited text file (csv) with upwards of 250 columns in it. In fact, it can have either 185 or 250! Furthermore, within this comma separated file, some of the values have commas in it (and no quotes or anything to offset). Nice huh? The file comes from a vendor, so that part is out of my hands.
Anyway, the purpose of the utility is to import the file and break the lines into two other files. The utility doesn't do anything to the file itself and there is no user interaction other than to select the file. All it does is bring it in, cycle through the lines, and put some of the lines in File A, and some of the in File B.
What I have done is to import the file using an oledb connection to read it in directly, and then .Fill a dataset/datatable. The default view of that table is used as the source for a hidden datagridview. The datagridview is used so that I can strip the commas out. For some reason, reading the csv file in with the oledb breaks it up correctly, allowing me to strip the commas out of the offending values.
However ... the REAL problem began when I realized what the .Fill was doing. The file contains huge account numbers. And the moment the account number hits the datatable from the .Fill method, it auto-converts to scientific notation! I have since modified my code to uncovert them on the way out. Which lead me to discover a new problem - that since the datatable is created using the values it starts with, later on there is data that doesn't fit the format - so that data is outright ignored and is not imported!
So - here is my question - how can I import from a text file and *ignore* data types? (or set them all to one type) I merely want to import everything as string columns! When I tried creating a table with string columns, all it did was append columns to the table (instead of 250, I had 250 strings (empty) and 250 import cols).
How can this be done? There HAS to be a way!
Start Free Trial