Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple Text file import

Status
Not open for further replies.

FoxFool

Programmer
Apr 15, 2004
10
0
0
US
Hey all. I am working on a project for a friend of mine and I have hit a road block.
I want to take a text file separated by commas or tabs, and import it into a table. Should be simple but the last field could be up to 500 characters long.
It would be great if I could import it into two 255 chr long fields. Either that or throw that field only into a memo field.
Is it possible to do a filetostr and search for the last chr(9), then replace from the 255 chr from that point with a chr(9)? Thanks for any help.
 
FoxFool,

Have a look at the RAT function - this looks for the last occurence of a string. Then the STUFF (I love that name!) function
STUFF(cExpression, nStartReplacement, nCharactersReplaced, cReplacement)
will allow you to insert character(s).


So you would end up with a command something like:
Code:
MyString = STUFF(MyString, RAT(CHR(9), MyString)+255,0,CHR(9))

However, I would suggest going the memo route:
[ol][li]is there any possibility that the last field could be over 500 characters?[/li][li]that long a string would be easier to read in a memo field[/li][/ol]

Hope that helps,

Stewart
PS If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top