Filtering Text Files

I have a program that can import Tab or colon delimited text files.
I can search the file for Chr(9) or Chr(58) and do a few other tests to see if the format is correct
What is the best way to limit the errors if the user tries to import a rich text file or even better allow them but some how find the text the user is intending for the import?

Havent tried yet and have no solution. But an idea: Read the files content into a TextArea (invisibe?) and read back the Value of the TextArea?

your question is too “large” to get a useful answer.

But, you know you can load a rtf file contents into a TextArea (apply the rtf data into RTFData).

Then, you are able to make a search into the TextArea styled (or not) text to find the delimiter you want.

Can’t test it right now:

t = TextInputStream.Open(f) t.Encoding = Encodings.UTF8 TextArea1.StyledText.RTFData = t.ReadAll

Maybe it’ll work?

Thanks, maybe the best idea from the above is to have a window with a Text area on the left showing what the user is trying to import have a convert button and on the left show the possible import and the user decides if it is ok?

Or place a TextArea outside of the visible space in your Window/Container :wink:

you could check for column headers first in the first row.

  • define a list with different spellings for each column.
    if all required columns exists read the file and validate each cell.
    if something is wrong put it into a error list with row numbers.
    if errors happened show import error list with correction suggestions.
    i would put each row into a structure or class before process.
    if you have a static import template put a version number into first cell.
    if csv file came from excel always maybe use office object to read excel files so user save time for export always.
    before import you could replace all line breaks (10 13,13 10,10,13) into your required line break char.


Hi Sasha, for the .rtf files the offscreen textarea works well and then Split the area using LF for the delimiter and then parsing the array with whatever delimiter was detected tab or colon… so far so good :slight_smile: