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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Text File

Status
Not open for further replies.

FRED123456789

Technical User
Jun 2, 2004
8
0
0
GB
Hi

I wonder if someone would be good enough to help

I need to remove two inverted commas from a text file so that the field reads

"204003","P20031216","961609",26

the only way i can get this file exported is

"204003","P20031216","961609","26"

am i missing somthing?

Thanks
 
I'm not sure I'm getting what you want to do, what do you mean by two inverted commas? Is this a table you are trying to export as an ascii file? I think I'm missing something.

Perrin
 
Hi

Sorry if i have been a little unclear

I have a script that will export a standard ascii file but we have a client that requires a modification to the last field so that the file does not display the last two inverted commas (around the 26 in my sample)

is there any way of removing these inverted commas after the export?

Thanks

 
If I understand correctly, your client needs the data delimeted by commas and all but the last field enclosed in quotes? There is no way I know of to export in that manner; however, you can use the text functions in OPAL to read each line of ASCII text in the exported file, modify it and then rewrite it.

Look at the readline() method in thehelp files to get started. You might consider using breakapart() to segregate each line into an array, then just work with the last element by removing the quotes and then reassembling the line before writing it back out to a file.

It seems odd that your client cannot simply do away with the quotes around all the fields. Most modern import functions in programs no longer require the quotes. I assume this is some sort of legacy software.

Mac :)

"There are only 10 kinds of people in this world... those who understand binary and those who don't"

langley_mckelvy@cd4.co.harris.tx.us
 
As langley said there is no easy way to export a table this way but it can be done in Opal, here is an example of code that will create an ascii table delimited on all but the 4th field.

Code:
method pushButton(var eventInfo Event)
var
    tc tcursor
    ts textStream
    ar array[] anytype
    el, delimiter, seperator anytype
    ars, x number
endvar

seperator = ","
delimiter = "\""

if not tc.open("export table") then
 errorshow()
endif
ts.open("test.txt", "nw")

scan tc:
 tc.copyToArray(ar)
 ars = ar.size()
 for x from 1 to ars
  if x = 4 then ; this will prevent the delimiter from being put on the 4th field, you can change this to any field or as many fields as you want
    ts.writestring(ar[x])
  else
    ts.writestring(delimiter+ar[x]+delimiter)
  endif
  if x <> ars then
    ts.writeString(seperator)
  endif
 endFor 
	ts.writeLine()
endscan
endMethod

Hope this helps
Perrin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top